|
|
|
@ -4,9 +4,13 @@ import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import javax.validation.Validator; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray; |
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.hxhq.business.domain.SystemLog; |
|
|
|
import com.hxhq.business.dto.select.BzListDto; |
|
|
|
import com.hxhq.business.dto.select.DeptUserTreeDto; |
|
|
|
import com.hxhq.business.form.common.SignForm; |
|
|
|
import com.hxhq.business.service.IRoleChangeService; |
|
|
|
import com.hxhq.business.service.ISystemLogService; |
|
|
|
import com.hxhq.business.utils.ObjectCompareUtil; |
|
|
|
import com.hxhq.system.api.domain.SysDept; |
|
|
|
@ -14,6 +18,7 @@ import com.hxhq.system.domain.SysMenu; |
|
|
|
import com.hxhq.system.domain.SysPost; |
|
|
|
import com.hxhq.system.domain.SysUserPost; |
|
|
|
import com.hxhq.system.domain.SysUserRole; |
|
|
|
import com.hxhq.system.form.UserSaveForm; |
|
|
|
import com.hxhq.system.service.ISysConfigService; |
|
|
|
import com.hxhq.system.service.ISysDeptService; |
|
|
|
import com.hxhq.system.service.ISysUserService; |
|
|
|
@ -75,6 +80,9 @@ public class SysUserServiceImpl implements ISysUserService |
|
|
|
@Autowired |
|
|
|
private ISystemLogService systemLogService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IRoleChangeService roleChangeService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据条件分页查询用户列表 |
|
|
|
* |
|
|
|
@ -296,15 +304,20 @@ public class SysUserServiceImpl implements ISysUserService |
|
|
|
/** |
|
|
|
* 修改保存用户信息 |
|
|
|
* |
|
|
|
* @param user 用户信息 |
|
|
|
* @param form 用户信息 |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public int updateUser(SysUser user) |
|
|
|
public int updateUser(UserSaveForm form) |
|
|
|
{ |
|
|
|
SysUser old = selectUserById(user.getUserId()); |
|
|
|
List<Long> oldRoleIdList = roleMapper.selectRoleListByUserId(user.getUserId()); |
|
|
|
SysUser user = form.getUser(); |
|
|
|
SignForm sign = form.getSign(); |
|
|
|
|
|
|
|
List<SystemLog> logList = getModifyLogList(user, sign); |
|
|
|
if(logList.size()>0){ |
|
|
|
systemLogService.saveBatch(logList); |
|
|
|
} |
|
|
|
|
|
|
|
Long userId = user.getUserId(); |
|
|
|
// 删除用户与角色关联 |
|
|
|
@ -316,14 +329,7 @@ public class SysUserServiceImpl implements ISysUserService |
|
|
|
// 新增用户与岗位管理 |
|
|
|
insertUserPost(user); |
|
|
|
|
|
|
|
int row = userMapper.updateUser(user); |
|
|
|
|
|
|
|
List<SystemLog> logList = getModifyLogList(user,old,oldRoleIdList); |
|
|
|
if(logList.size()>0){ |
|
|
|
systemLogService.saveBatch(logList); |
|
|
|
} |
|
|
|
|
|
|
|
return row; |
|
|
|
return userMapper.updateUser(user); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -638,7 +644,10 @@ public class SysUserServiceImpl implements ISysUserService |
|
|
|
return userMapper.selectNamesByIdList(idList); |
|
|
|
} |
|
|
|
|
|
|
|
private List<SystemLog> getModifyLogList(SysUser info, SysUser old, List<Long> oldRoleIdList){ |
|
|
|
private List<SystemLog> getModifyLogList(SysUser info, SignForm sign){ |
|
|
|
SysUser old = selectUserById(info.getUserId()); |
|
|
|
List<Long> oldRoleIdList = roleMapper.selectRoleListByUserId(info.getUserId()); |
|
|
|
|
|
|
|
List<SystemLog> list = new ArrayList<>(); |
|
|
|
|
|
|
|
List<ObjectCompareUtil.FieldChange> fieldChanges = ObjectCompareUtil.compareObjects(old, info); |
|
|
|
@ -677,6 +686,8 @@ public class SysUserServiceImpl implements ISysUserService |
|
|
|
} |
|
|
|
} |
|
|
|
if(updateRole){ |
|
|
|
checkPassword(SecurityUtils.getLoginUser().getSysUser(),sign.getQmrmm(),false); |
|
|
|
|
|
|
|
List<SysRole> allRoleList = roleMapper.selectRoleList(new SysRole()); |
|
|
|
|
|
|
|
List<SysRole> oldRoleList = new ArrayList<>(); |
|
|
|
@ -692,11 +703,15 @@ public class SysUserServiceImpl implements ISysUserService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<String> oldRoleNameList = oldRoleList.stream().map(o->o.getRoleName()).collect(Collectors.toList()); |
|
|
|
List<String> bghList = oldRoleList.stream().map(o->o.getRoleName()).collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<String> addNameList = new ArrayList<>(); |
|
|
|
List<String> deleteNameList = new ArrayList<>(); |
|
|
|
for(SysRole newRole : newRoleList){ |
|
|
|
if(!oldRoleIdList.contains(newRole.getRoleId())){ |
|
|
|
addNameList.add(newRole.getRoleName()); |
|
|
|
bghList.add(newRole.getRoleName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -704,15 +719,17 @@ public class SysUserServiceImpl implements ISysUserService |
|
|
|
for(SysRole oldRole : oldRoleList){ |
|
|
|
if(!newMenuIdList.contains(oldRole.getRoleId())){ |
|
|
|
deleteNameList.add(oldRole.getRoleName()); |
|
|
|
bghList.remove(oldRole.getRoleName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(addNameList.size()>0 || deleteNameList.size()>0){ |
|
|
|
SystemLog log = getLogInfo(old); |
|
|
|
log.setJcnr((addNameList.size()>0?("新增角色:"+String.join(",",addNameList)):"")+(deleteNameList.size()>0?(";删除角色:"+String.join(",",deleteNameList)):"")); |
|
|
|
log.setJcnrEn((addNameList.size()>0?("Add Role:"+String.join(",",addNameList)):"")+(deleteNameList.size()>0?(";Remove Role:"+String.join(",",deleteNameList)):"")); |
|
|
|
log.setJcnr((addNameList.size()>0?("新增角色:"+String.join(",",addNameList)):"")+(deleteNameList.size()>0?(";删除角色:"+String.join(",",deleteNameList)):"")+(StringUtils.isBlank(sign.getRemark())?"":";备注:"+sign.getRemark())); |
|
|
|
log.setJcnrEn((addNameList.size()>0?("Add Role:"+String.join(",",addNameList)):"")+(deleteNameList.size()>0?(";Remove Role:"+String.join(",",deleteNameList)):"")+(StringUtils.isBlank(sign.getRemark())?"":";Comment:"+sign.getRemark())); |
|
|
|
list.add(log); |
|
|
|
} |
|
|
|
roleChangeService.saveInfo(info.getUserId(),String.join(",",oldRoleNameList),String.join(",",bghList),sign.getRemark()); |
|
|
|
} |
|
|
|
|
|
|
|
return list; |
|
|
|
@ -725,8 +742,9 @@ public class SysUserServiceImpl implements ISysUserService |
|
|
|
private SystemLog getLogInfo(SysUser sysUser){ |
|
|
|
SystemLog log = new SystemLog(); |
|
|
|
log.setName(sysUser.getNickName()); |
|
|
|
log.setJcmc("修改用户"); |
|
|
|
log.setJcmcEn("Modify User"); |
|
|
|
log.setNameEn(sysUser.getNickName()); |
|
|
|
log.setJcmc("编辑用户"); |
|
|
|
log.setJcmcEn("Edit User"); |
|
|
|
log.setQmrId(SecurityUtils.getUserId()); |
|
|
|
log.setQmrMc(SecurityUtils.getNickName()); |
|
|
|
log.setQmrMcEn(SecurityUtils.getUsername()); |
|
|
|
|