提交 041c640b authored 作者: zjm's avatar zjm

fix(单位模块): 添加用户修改后 加入档案

添加用户修改后 加入档案
上级 7fe91103
......@@ -3,6 +3,7 @@ package com.tykj.dev.device.user.subject.controller;
import com.tykj.dev.config.swagger.AutoDocument;
import com.tykj.dev.device.user.base.req.*;
import com.tykj.dev.device.user.base.ret.UserUpdatePw;
import com.tykj.dev.device.user.cache.UserCache;
import com.tykj.dev.device.user.config.MyFilter;
import com.tykj.dev.device.user.config.MyUserDetailsServiceImpl;
import com.tykj.dev.device.user.subject.entity.SecurityUser;
......@@ -59,6 +60,9 @@ public class UserController {
@Autowired
LogoutUtil logout;
@Autowired
UserCache userCache;
@Autowired
MyWebSocket myWebSocket;
// @PostMapping(value = "/login")
......@@ -112,7 +116,8 @@ public class UserController {
@PostMapping(value = "/update")
@ApiOperation(value = "用户更新接口", notes = "更新成功返回用户对象")
public ResponseEntity updateUser(@RequestBody User user) {
return ResponseEntity.ok(userService.update(user));
return ResponseEntity.ok(userService.update(user));
}
@GetMapping(value = "/findAll")
......
......@@ -17,6 +17,7 @@ import com.tykj.dev.device.user.subject.dao.UserDao;
import com.tykj.dev.device.user.subject.dao.UserRoleDao;
import com.tykj.dev.device.user.subject.entity.*;
import com.tykj.dev.device.user.subject.service.*;
import com.tykj.dev.device.user.util.UserUtils;
import com.tykj.dev.misc.exception.ApiException;
import com.tykj.dev.misc.utils.SpringUtils;
import lombok.extern.slf4j.Slf4j;
......@@ -163,18 +164,44 @@ public class UserServiceImpl implements UserService {
return userDao.findAll();
}
@Autowired
UserUtils userUtils;
@Override
public User update(User user) {
Optional<User> userOptional = userDao.findById(user.getUserId());
if (userOptional.isPresent()){
User user1= userOptional.get();
user.setNoPassword(user1.getNoPassword());
user.setShowOrder(user1.getShowOrder());
user.setTrainStatus(user1.getTrainStatus());
user.setIsDel(user1.getIsDel());
}else {
throw new ApiException(ResponseEntity.status(500).body("没找到对应的用户id"));
User oldUser=userCache.findById(user.getUserId());
if (!oldUser.getName().equals(user.getName())){
userLogService.save(new UserLog(userUtils.getCurrentUserId(),new Date(),"修改信息 名称:"+oldUser.getName()+"->"+user.getName()));
}
if (!oldUser.getMobile().equals(user.getMobile())){
userLogService.save(new UserLog(userUtils.getCurrentUserId(),new Date(),"修改信息 手机号码:"+oldUser.getMobile()+"->"+user.getMobile()));
}
if (!oldUser.getSex().equals(user.getSex())){
userLogService.save(new UserLog(userUtils.getCurrentUserId(),new Date(),"修改信息 性别:"+(oldUser.getSex()==0 ? "男" : "女")+"->"+(user.getSex()==0 ? "男" : "女")));
}
if (!oldUser.getPosition().equals(user.getPosition())){
userLogService.save(new UserLog(userUtils.getCurrentUserId(),new Date(),"修改信息 职位:"+ (oldUser.getPosition()==0 ? "领导" : "职员")+"->"+(user.getPosition()==0 ? "领导" : "职员")));
}
if (!oldUser.getEmail().equals(user.getEmail())){
userLogService.save(new UserLog(userUtils.getCurrentUserId(),new Date(),"修改信息 邮箱:"+oldUser.getEmail()+"->"+user.getEmail()));
}
if (!oldUser.getIdCard().equals(user.getIdCard())){
userLogService.save(new UserLog(userUtils.getCurrentUserId(),new Date(),"修改信息 身份证:"+oldUser.getIdCard()+"->"+user.getIdCard()));
}
if (!oldUser.getTelphone().equals(user.getTelphone())){
userLogService.save(new UserLog(userUtils.getCurrentUserId(),new Date(),"修改信息 固定电话:"+oldUser.getTelphone()+"->"+user.getTelphone()));
}
user.setNoPassword(oldUser.getNoPassword());
user.setShowOrder(oldUser.getShowOrder());
user.setTrainStatus(oldUser.getTrainStatus());
user.setIsDel(oldUser.getIsDel());
User user1 = userDao.save(user);
userCache.refresh(userDao.findAll());
return user1;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论