Commit 2acbd4e5 authored by 赵啸非's avatar 赵啸非

Merge branch 'master' into reg

# Conflicts:
#	log-manager/src/main/java/com/mortals/xhx/base/framework/interceptor/AuthTokenServiceImpl.java
parents 0462f743 7872d6b0
......@@ -47,7 +47,7 @@
fuzzy: true
},
{
name: "appName",
name: "targetServer",
type: "text",
label: "应用名称",
fuzzy: true
......
......@@ -60,7 +60,7 @@
{
name: "deviceCode",
type: "text",
label: "设备唯一标识",
label: "设备Id",
fuzzy: true
},
{
......@@ -98,7 +98,7 @@
{label: "用户标识", prop: "userCode"},
{label: "设备标识", prop: "deviceCode"},
{label: "设备ID", prop: "deviceCode"},
{label: "事件主题", prop: "eventTopic"},
......
......@@ -38,7 +38,6 @@
toView(row) {
this.$refs.drawerform.view(row);
},
},
data() {
return {
......@@ -47,7 +46,7 @@
{
name: "traceID",
type: "text",
label: "TraceId",
label: "追踪Id",
fuzzy: true
},
{
......@@ -81,7 +80,7 @@
{type: "index",label: "序号",align:"center",width: 50},
{label: "追踪Id", prop: "id"},
{label: "TraceID", prop: "traceID"},
{label: "日志来源", prop: "appName",formatter:this.formatter},
......
......@@ -188,25 +188,25 @@
</profile>
<profile>
<id>sngx</id>
<id>xuanhan</id>
<properties>
<profiles.active>sngx</profiles.active>
<profiles.server.ip>127.0.0.1</profiles.server.ip>
<profiles.active>yibin</profiles.active>
<profiles.server.ip>192.168.2.144</profiles.server.ip>
<profiles.server.port>18225</profiles.server.port>
<profiles.nginx.port>11092</profiles.nginx.port>
<profiles.server.gatewayport>11078</profiles.server.gatewayport>
<profiles.server.path>/logservice</profiles.server.path>
<profiles.server.path>/logService</profiles.server.path>
<profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.datasource.uri>
<![CDATA[jdbc:mysql://127.0.0.1:3306/log-platform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong]]></profiles.datasource.uri>
<profiles.datasource.username>root</profiles.datasource.username>
<profiles.datasource.password>root</profiles.datasource.password>
<profiles.datasource.password>xhx@2022</profiles.datasource.password>
<profiles.redis.uri>127.0.0.1</profiles.redis.uri>
<profiles.redis.port>6379</profiles.redis.port>
<profiles.redis.username></profiles.redis.username>
<profiles.redis.password>hotel@2020</profiles.redis.password>
<profiles.redis.database>9</profiles.redis.database>
<profiles.rabbitmq.host>192.168.0.250</profiles.rabbitmq.host>
<profiles.rabbitmq.host>127.0.0.1</profiles.rabbitmq.host>
<profiles.rabbitmq.port>5672</profiles.rabbitmq.port>
<profiles.rabbitmq.username>taxi_mq</profiles.rabbitmq.username>
<profiles.rabbitmq.password>admin@2020</profiles.rabbitmq.password>
......@@ -215,10 +215,10 @@
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.log.path>/home/mortals/app/logs</profiles.log.path>
<profiles.filepath>/mortals/app/data</profiles.filepath>
<package.environment>build</package.environment>
<skipDeploy>false</skipDeploy>
<profiles.log.path>D:/home/mortals/app/logs</profiles.log.path>
<profiles.filepath>D:/mortals/app/data</profiles.filepath>
<package.environment>yibin</package.environment>
<skipDeploy>true</skipDeploy>
</properties>
</profile>
......
......@@ -94,10 +94,12 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
String uuid = (String) claims.get(SysConstains.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid);
/* cacheService.select(portalDb);
String userStr = cacheService.get(userKey);*/
String userStr = cacheService.get(userKey);
cacheService.select(db);*/
RedisTemplate<String, String> redisTemplate = cacheService.selectDbRedisTemplate(portalDb);
String userStr =redisTemplate.opsForValue().get(userKey);
// cacheService.select(db);
if (StringUtils.isNotEmpty(userStr)) {
UserEntity userEntity = JSONObject.parseObject(userStr, UserEntity.class);
userEntity.setToken(token);
......
......@@ -81,10 +81,10 @@ public class AccessMessageConsumerListener {
entity.setCreateUserId(1L);
entity.setCreateTime(new Date());
//判断 超过一定时间的请求 才记录
// if (!ObjectUtils.isEmpty(entity.getDuration()) && entity.getDuration() < Constant.ACCESS_EXPIRE_TIME) {
// // log.info("Duration:{}",entity.getDuration());
// return null;
// }
if (!ObjectUtils.isEmpty(entity.getDuration()) && entity.getDuration() < Constant.ACCESS_EXPIRE_TIME) {
// log.info("Duration:{}",entity.getDuration());
return null;
}
return entity;
} catch (Exception e) {
log.info("反序列化异常", e);
......
......@@ -8,11 +8,10 @@
package com.mortals.xhx.base.system.user.dao.ibatis;
import com.mortals.xhx.base.system.user.dao.UserDao;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import com.mortals.framework.model.ParamDto;
import com.mortals.xhx.base.system.user.dao.UserDao;
import com.mortals.xhx.base.system.user.model.UserEntity;
import org.springframework.stereotype.Repository;
import java.util.List;
......
......@@ -131,8 +131,7 @@ public class UserEntity extends UserVo implements IUser {
@Override
public boolean isAdmin() {
return true;
// return super.getId() == null ? false : super.getId().longValue() == SysConstains.ADMIN_ID;
return super.getId() == null ? false : super.getId().longValue() == SysConstains.ADMIN_ID;
}
@Override
......
package com.mortals.xhx.base.system.user.model;
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
import java.util.List;
/**
* Description:User
* date: 2021-9-26 16:11:48
*/
@Data
public class UserEntityExt extends BaseEntityLong {
/**
* 站点名称
*/
private String siteName;
private String roleIds;
/**
* 唯一标识
*/
private String token;
/**
* 菜单栏
*/
private String menuUrl;
/**
* 登录时间
*/
private Long loginTime;
/**
* 过期时间
*/
private Long expireTime;
}
\ No newline at end of file
package com.mortals.xhx.base.system.user.model;
import java.util.Date;
import java.util.List;
/**
* 用户信息业务查询对象
......
......@@ -4,9 +4,6 @@ package com.mortals.xhx.base.system.user.model.vo;
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 用户信息业务视图对象
*
......@@ -15,6 +12,7 @@ import java.util.List;
*/
@Data
public class UserVo extends BaseEntityLong {
/**
* 站点名称
*/
......@@ -39,4 +37,8 @@ public class UserVo extends BaseEntityLong {
* 过期时间
*/
private Long expireTime;
private String oldPassword;
private String newPassword;
private String siteIds;
}
\ No newline at end of file
......@@ -8,9 +8,9 @@
package com.mortals.xhx.base.system.user.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICRUDService;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.IUser;
import com.mortals.xhx.base.system.menu.model.MenuEntity;
import com.mortals.xhx.base.system.user.dao.UserDao;
......@@ -28,17 +28,9 @@ import java.util.Set;
* @version 1.0.0
*/
public interface UserService extends ICRUDService<UserEntity,Long> {
/**
* 用户登录
*
* @param loginName 登录用户名
* @param password 登录密码
* @param loginIp 登录IP
* @return
* @throws AppException
*/
UserEntity doLogin(String loginName, String password, String loginIp) throws AppException;
public interface UserService extends ICRUDCacheService<UserEntity,Long> {
/**
* 校验用户名与密码是否正确
......@@ -50,15 +42,6 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
*/
UserEntity doCheckUser(String loginName, String password) throws AppException;
/**
* 检查用户是否存在
*
* @param loginName 登录用户名
* @param userId 密码
* @return
*/
boolean existUser(String loginName, Long userId) throws AppException;
/**
* 通过登录用户获取菜单功能权限
*
......@@ -75,46 +58,7 @@ public interface UserService extends ICRUDService<UserEntity,Long> {
*/
Set<Long> findAllAuthIds(UserEntity userEntity) throws AppException;
/**
* 查询用户记录
*
* @param platformId
* @param params
* @param currPage
* @param prePageResult
* @return
* @throws AppException
*/
Result<UserEntity> find(Long platformId, UserEntity params, int currPage, int prePageResult) throws AppException;
/**
* 为客户创建用户
*
* @param currUser 当前用户
* @param customerId 客户ID
* @param customerName 客户名称
* @param loginName
* @param password
* @param userName
* @param mobile
* @return
* @throws AppException
*/
UserEntity createUser(IUser currUser, Long customerId, String customerName, String loginName, String password,
String userName, String mobile) throws AppException;
/**
* 用户修改密码
*
* @param loginName
* @param oldPwd
* @param newPwd
* @return
* @throws AppException
*/
boolean updateUserPwd(String loginName, String oldPwd, String newPwd) throws AppException;
Rest<Void> refreshUser();
UserDao getUserDao();
......
/**
* 文件:UserController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.user.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.Rest;
import com.mortals.framework.common.code.UserType;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.framework.annotation.Operlog;
import com.mortals.xhx.base.system.role.model.RoleQuery;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.UserStatus;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 用户信息
*
* @author: zxfei
* @date: 2022/5/7 15:42
* <p>Title: 用户信息</p>
* <p>Description: UserController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
@RestController
@RequestMapping("user")
......@@ -46,91 +42,28 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
@Autowired
private RoleService roleService;
@Autowired
private RoleUserService roleUserService;
public UserController() {
super.setFormClass(UserForm.class);
super.setModuleDesc("用户信息");
}
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model,"userType", IBaseEnum.getEnumMap(UserType.class));
this.addDict(model,"status", UserStatus.getEnumMap());
this.addDict(model, "roleIds", roleService.find(new RoleQuery()).stream().collect(Collectors.toMap(x -> x.getId().toString(), y -> y.getName())));
}
@Override
protected void doListBefore(UserEntity query, Map<String, Object> model, Context context) throws AppException {
if (!StringUtils.isEmpty(query.getRealName())) {
query.setRealName("%".concat(query.getRealName()).concat("%"));
List<RoleEntity> roleList = roleService.find(new RoleEntity());
this.addDict(model,"roleId", roleList.stream().collect(Collectors.toMap(e->e.getId().toString(), e->e.getName())));
super.init(model, context);
}
if (!StringUtils.isEmpty(query.getLoginName())) {
query.setLoginName("%".concat(query.getLoginName()).concat("%"));
}
}
@Override
protected int editAfter(Long id, Map<String, Object> model, UserEntity entity, Context context) throws AppException {
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(entity.getId());
String roleIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getRoleId).map(String::valueOf).collect(Collectors.joining(","));
entity.setRoleIds(roleIds);
return super.editAfter(id, model, entity, context);
}
@Override
protected int saveAfter(UserEntity entity, Map<String, Object> model, Context context) throws AppException {
if (entity.getId() == getCurUser().getId()) {
// TODO: 2022/8/15 更新redis session信息
//saveCurrUserForSession(request, response, userService.get(form.getEntity().getId(), false));
}
return super.saveAfter(entity, model, context);
}
// @Override
// protected void saveBefore(UserEntity entity, Map<String, Object> model, Context context) throws AppException {
// if (!ObjectUtils.isEmpty(entity.getLoginName()) && service.existUser(entity.getLoginName(), entity.getId())) {
// throw new AppException("登录名已存在!");
// }
// super.saveBefore(entity, model, context);
// }
@RequestMapping(value = "change/password", method = RequestMethod.POST)
@Operlog(msg = "密码修改成功!")
public String changePassword(@RequestParam String oldPwd, @RequestParam String newPwd) {
JSONObject ret = new JSONObject();
try {
service.updateUserPwd(super.getCurUser().getLoginName(), oldPwd, newPwd);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "密码修改成功!");
} catch (Exception e) {
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
}
return ret.toJSONString();
}
public static void main(String[] args) {
String token = "eyJhbGciOiJIUzI1NiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIzNGE5NDA5ZDVhOTQ3MWNhMzdkYjZkYmMwY2JjZTc5In0.MWyQW40HYDxyUz7PJRf_nRsFPWx3Hr811Ime984nixs";
String secret = "026db82420614469897fcc2dc1b4ce38";
Claims claims = Jwts.parser()
.setSigningKey(Base64.getEncoder().encodeToString(secret.getBytes()))
.parseClaimsJws(token)
.getBody();
String uuid = (String) claims.get("login_user_key");
System.out.println(uuid);
@PostMapping({"refreshUser"})
@UnAuth
public Rest<Object> refreshUser() {
log.info("刷新用户");
this.service.refreshUser();
return Rest.ok("用户同步刷新操作成功");
}
}
\ No newline at end of file
/**
* 文件:UserForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.user.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
/**
* <p>Title: 用户信息</p>
* <p>Description: UserForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class UserForm extends BaseCRUDFormLong<UserEntity> {
private UserEntity entity = new UserEntity();
private UserQuery query = new UserQuery();
public UserForm(){
}
@Override
public UserEntity getEntity() {
return entity;
}
public void setEntity(UserEntity entity) {
this.entity = entity;
}
@Override
public UserQuery getQuery() {
return query;
}
public void setQuery(UserQuery query) {
this.query = query;
}
}
\ No newline at end of file
......@@ -115,8 +115,8 @@ public final class Constant {
public static final String DISTRIBUTE_PATH = "distribute_path";
/**
* 访问超时时间,默认2
* 访问超时时间,默认1
*/
public static final Long ACCESS_EXPIRE_TIME = 2000L;
public static final Long ACCESS_EXPIRE_TIME = 1000L;
}
package com.mortals.xhx.daemon.applicationservice;
import com.mortals.framework.springcloud.service.IApplicationStartedService;
import com.mortals.framework.util.ThreadPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 应用级服务,在应用启动后、停止过程中调用
* 应用已经完成启动完成,才调用该服务
* 应用场景:
* 1、应用任务,应用启动后定时或间隔执行的任务
* 2、Socket服务端
*/
@Component
@Slf4j
public class DemoStartedService implements IApplicationStartedService {
@Override
public void start() {
ThreadPool.getInstance().init(10);
}
@Override
public void stop() {
log.info("停止服务..");
}
@Override
public int getOrder() {
return 10;
}
}
package com.mortals.xhx.daemon.task;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.feign.user.IUserFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Service;
/**
* 同步用户
*/
@Slf4j
@Service("SyncUserTask")
@ConditionalOnExpression("'${spring.profiles.active}'!='develop'")
public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private UserService userService;
@Autowired
private IUserFeign userFeign;
@Override
public void excuteTask(ITask task) throws AppException {
userService.refreshUser();
log.info("同步用户");
/* UserPdu userPdu = new UserPdu();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu);
userService.updateUserList(list.getData().getData());*/
//resourceService.updateUserList();
/* UserPdu userPdu = new UserPdu();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> list = userFeign.list(userPdu);
*//* List<UserPdu> firstList = list.getData().getData();
List<UserEntity> secondList = userService.find(new UserQuery());
//交叉对比后,多的新增 少的删除
List<UserEntity> diffList = secondList.parallelStream()
.filter(item -> !firstList.parallelStream().map(e -> e.getId()).collect(Collectors.toList()).contains(item.getId()))
.collect(Collectors.toList());*//*
//log.info("diffList:{}",JSON.toJSONString(diffList));
//更新本地用户信息,并且更新用户站点树
list.getData().getData().forEach(user -> {
//查询用户是否存在,
//UserEntity userEntity = userService.get(user.getId());
UserEntity userEntity =userService.selectOne(new UserQuery().loginName(user.getLoginName()));
if (ObjectUtils.isEmpty(userEntity)) {
//新增
UserEntity entity = new UserEntity();
entity.initAttrValue();
BeanUtils.copyProperties(user, entity, BeanUtil.getNullPropertyNames(user));
userService.save(entity);
Context context = new Context();
context.setUser(entity);
new Thread(new SyncTreeSiteThread(siteService, context)).start();
}
});*/
}
@Override
public void stopTask(ITask task) throws AppException {
}
}
......@@ -87,20 +87,20 @@
</trim>
</sql>
<!-- 新增 区分主键自增加还是业务插入 -->
<insert id="insert" parameterType="UserEntity" useGeneratedKeys="true" keyProperty="id">
<insert id="insert" parameterType="UserEntity" >
insert into mortals_xhx_user
(loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,siteIds,areaCodes,status,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress)
(id,loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,siteIds,areaCodes,status,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress)
VALUES
(#{loginName},#{loginPwd},#{loginLimitAddress},#{realName},#{mobile},#{phone},#{email},#{qq},#{userType},#{siteIds},#{areaCodes},#{status},#{createTime},#{createUserId},#{createUserName},#{lastLoginTime},#{lastLoginAddress})
(#{id},#{loginName},#{loginPwd},#{loginLimitAddress},#{realName},#{mobile},#{phone},#{email},#{qq},#{userType},#{siteIds},#{areaCodes},#{status},#{createTime},#{createUserId},#{createUserName},#{lastLoginTime},#{lastLoginAddress})
</insert>
<!-- 批量新增 -->
<insert id="insertBatch" parameterType="paramDto">
insert into mortals_xhx_user
(loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,siteIds,areaCodes,status,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress)
(id,loginName,loginPwd,loginLimitAddress,realName,mobile,phone,email,qq,userType,siteIds,areaCodes,status,createTime,createUserId,createUserName,lastLoginTime,lastLoginAddress)
VALUES
<foreach collection="data.dataList" item="item" index="index" separator="," >
(#{item.loginName},#{item.loginPwd},#{item.loginLimitAddress},#{item.realName},#{item.mobile},#{item.phone},#{item.email},#{item.qq},#{item.userType},#{item.siteIds},#{item.areaCodes},#{item.status},#{item.createTime},#{item.createUserId},#{item.createUserName},#{item.lastLoginTime},#{item.lastLoginAddress})
(#{item.id},#{item.loginName},#{item.loginPwd},#{item.loginLimitAddress},#{item.realName},#{item.mobile},#{item.phone},#{item.email},#{item.qq},#{item.userType},#{item.siteIds},#{item.areaCodes},#{item.status},#{item.createTime},#{item.createUserId},#{item.createUserName},#{item.lastLoginTime},#{item.lastLoginAddress})
</foreach>
</insert>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.iot.base.system.user.dao.ibatis.UserDaoImpl">
<!-- 获取列表 -->
<select id="getAuthListById" parameterType="paramDto" resultType="Long">
select resourceId
from mortals_iot_role_auth as a
left join mortals_iot_role_user as b
on a.roleId=b.roleId
where b.userId=#{condition.id}
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment