Browse Source

fix update password error

master
weihaonan 1 year ago
parent
commit
4290886554
5 changed files with 25 additions and 16 deletions
  1. +2
    -2
      src/main/java/com/whn/hellospring/controller/RoleController.java
  2. +12
    -5
      src/main/java/com/whn/hellospring/controller/UserController.java
  3. +4
    -2
      src/main/java/com/whn/hellospring/log/OperationLogAspect.java
  4. +1
    -1
      src/main/java/com/whn/hellospring/service/UserService.java
  5. +6
    -6
      src/main/resources/application.yml

+ 2
- 2
src/main/java/com/whn/hellospring/controller/RoleController.java View File

@ -48,10 +48,10 @@ public class RoleController {
return new Status(StateMessage.TOKEN_ERROR);
}
if(request.getId()!=null){
if(request.getP_id()!=null){
// 获取角色详情
RoleDO roleDetail = roleService.getRoleWithId(request.getId());
RoleDO roleDetail = roleService.getRoleWithId(Long.parseLong(request.getP_id()));
if(roleDetail==null){
return new Status(StateMessage.SUCCESS, "此id角色不存在");


+ 12
- 5
src/main/java/com/whn/hellospring/controller/UserController.java View File

@ -52,11 +52,18 @@ public class UserController {
return new Status(StateMessage.SUCCESS, "此id用户不存在");
}
//编辑 信息
UserDO userDO = MergeObjectsUtil.mergeObjects(request, userDetail);
userService.updateUser(userDO);
return new Status(StateMessage.SUCCESS, userDO);
//有密码覆盖密码加密
if(request.getUserPassword()!=null && !"".equals(request.getUserPassword())){
userDetail.setUserPassword(request.getUserPassword());
UserDO userDO = MergeObjectsUtil.mergeObjects(request, userDetail);
userService.updateUser(userDO);
return new Status(StateMessage.SUCCESS, userDO);
}else{
//没有密码不重新加密
UserDO userDO = MergeObjectsUtil.mergeObjects(request, userDetail);
userService.updateUserNoPassword(userDO);
return new Status(StateMessage.SUCCESS, userDO);
}
}else{
//新增


+ 4
- 2
src/main/java/com/whn/hellospring/log/OperationLogAspect.java View File

@ -78,8 +78,10 @@ public class OperationLogAspect {
try {
if(request.getHeader("token")!=null){
UserDO user = userService.getUserWithToken(request.getHeader("token"));
operationLog.setUser_id(user.getId().toString());
operationLog.setUser_name(user.getUserName());
if(user!=null){
operationLog.setUser_id(user.getId().toString());
operationLog.setUser_name(user.getUserName());
}
}
}catch (Exception e){
System.out.println("e:"+e.toString());


+ 1
- 1
src/main/java/com/whn/hellospring/service/UserService.java View File

@ -132,7 +132,7 @@ public class UserService {
}
/**
* 编辑客户
* 编辑客户加密密码
*/
public UserDO updateUser(UserDO userDo) {
userDo.setUserPassword(SHAUtils.getSHA256StrJava(userDo.getUserPassword()));


+ 6
- 6
src/main/resources/application.yml View File

@ -22,13 +22,13 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://101.37.147.15:3306/AgileTools?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL
username: root
password: root
password: Digiproto@123
#数据源2
# zentao:
# driver-class-name: com.mysql.cj.jdbc.Driver
# url: jdbc:mysql://101.37.147.15:23306/zentao?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL
# username: root
# password: 123456
zentao:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://101.37.147.15:23306/zentao?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=CONVERT_TO_NULL
username: root
password: Digiproto@123
# url: jdbc:mysql://101.37.147.15:3306/AgileTools?useUnicode=true&characterEncoding=UTF-8?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&failOverReadOnly=false&serverTimezone=UTC
# username: root


Loading…
Cancel
Save