|
@@ -257,21 +257,26 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
|
|
|
String errorInfo = null;
|
|
String errorInfo = null;
|
|
|
|
|
|
- if (StringUtils.isEmpty(roleName)) {
|
|
|
|
|
|
+ if (StringUtils.isEmpty(roleName) || dept == null) {
|
|
errorInfo = "角色名称为空";
|
|
errorInfo = "角色名称为空";
|
|
} else {
|
|
} else {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<String> roleNames = roleName.contains(StrUtil.SLASH) ? StrUtil.split(roleName, StrUtil.SLASH) : Collections.singletonList(roleName);
|
|
|
|
+
|
|
// 根据角色名称获取角色
|
|
// 根据角色名称获取角色
|
|
- SysRole sysRole = sysRoleService.getOne(Wrappers.<SysRole>lambdaQuery()
|
|
|
|
- .eq(SysRole::getRoleName, roleName)
|
|
|
|
- .eq(SysRole::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
- if (sysRole == null) {
|
|
|
|
|
|
+ List<Integer> sysRole = sysRoleService.list(Wrappers.<SysRole>lambdaQuery()
|
|
|
|
+ .in(SysRole::getRoleName, roleNames)
|
|
|
|
+ .eq(SysRole::getDelFlag, DelEnum.NOT_DEL.getVal())).stream().mapToInt(SysRole::getRoleId).boxed().distinct().collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ if (CollUtil.isEmpty(sysRole)) {
|
|
errorInfo = "角色不存在或者未启用";
|
|
errorInfo = "角色不存在或者未启用";
|
|
} else {
|
|
} else {
|
|
- userDTO.setRole(Collections.singletonList(sysRole.getRoleId()));
|
|
|
|
|
|
+ userDTO.setRole(sysRole);
|
|
if (userDTO.getRole().contains(2)) {
|
|
if (userDTO.getRole().contains(2)) {
|
|
UserDTO tmp = new UserDTO();
|
|
UserDTO tmp = new UserDTO();
|
|
tmp.setUsername(userDTO.getUsername());
|
|
tmp.setUsername(userDTO.getUsername());
|
|
- tmp.setDelFlag("0");
|
|
|
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
if (CollUtil.isNotEmpty(userVoList)) {
|
|
if (CollUtil.isNotEmpty(userVoList)) {
|
|
for (UserVO userVO : userVoList) {
|
|
for (UserVO userVO : userVoList) {
|
|
@@ -296,6 +301,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
if (r.getRoleId() == 7) {
|
|
if (r.getRoleId() == 7) {
|
|
errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为财务管理员!";
|
|
errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为财务管理员!";
|
|
}
|
|
}
|
|
|
|
+ if (r.getRoleId() == 31) {
|
|
|
|
+ errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为招商经理";
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -304,7 +312,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
} else if (userDTO.getRole().contains(3)) {
|
|
} else if (userDTO.getRole().contains(3)) {
|
|
UserDTO tmp = new UserDTO();
|
|
UserDTO tmp = new UserDTO();
|
|
tmp.setUsername(userDTO.getUsername());
|
|
tmp.setUsername(userDTO.getUsername());
|
|
- tmp.setDelFlag("0");
|
|
|
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
if (CollUtil.isNotEmpty(userVoList)) {
|
|
if (CollUtil.isNotEmpty(userVoList)) {
|
|
for (UserVO userVO : userVoList) {
|
|
for (UserVO userVO : userVoList) {
|
|
@@ -328,16 +336,16 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- } else if (userDTO.getRole().contains(4)) {
|
|
|
|
|
|
+ } else if (userDTO.getRole().contains(4) || userDTO.getRole().contains(37)) {
|
|
UserDTO tmp = new UserDTO();
|
|
UserDTO tmp = new UserDTO();
|
|
tmp.setUsername(userDTO.getUsername());
|
|
tmp.setUsername(userDTO.getUsername());
|
|
- tmp.setDelFlag("0");
|
|
|
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
List<UserVO> userVoList = sysUserMapper.selectByPhone(tmp);
|
|
if (CollUtil.isNotEmpty(userVoList)) {
|
|
if (CollUtil.isNotEmpty(userVoList)) {
|
|
for (UserVO userVO : userVoList) {
|
|
for (UserVO userVO : userVoList) {
|
|
if (null != userVO.getRoleList()) {
|
|
if (null != userVO.getRoleList()) {
|
|
for (SysRole r : userVO.getRoleList()) {
|
|
for (SysRole r : userVO.getRoleList()) {
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
|
|
|
+ if (r.getRoleId() == 2) {
|
|
errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为!";
|
|
errorInfo = errorInfo + "用户已存在平台管理员角色,不能同时为!";
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -357,6 +365,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (r.getRoleId() == 31) {
|
|
|
|
+ SysUserRole sysUserRole = new SysUserRole();
|
|
|
|
+ sysUserRole.setUserId(userVO.getUserId());
|
|
|
|
+ List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
|
+ for (SysUserRole userRole : sysUserRoleList) {
|
|
|
|
+ SysUser sysUser = getById(userRole.getUserId());
|
|
|
|
+ if (!sysUser.getDeptId().equals(userDTO.getDeptId())) {
|
|
|
|
+ errorInfo = errorInfo + "用户已存在招商经理角色,不能为其他机构CSO管理员";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -453,7 +472,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
for (UserVO userVO : userVoList) {
|
|
for (UserVO userVO : userVoList) {
|
|
if (null != userVO.getRoleList()) {
|
|
if (null != userVO.getRoleList()) {
|
|
for (SysRole r : userVO.getRoleList()) {
|
|
for (SysRole r : userVO.getRoleList()) {
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
|
|
|
+ if (r.getRoleId() == 2) {
|
|
errorInfo = errorInfo + "用户已存在平台管理员,不能同时为CRO管理员!";
|
|
errorInfo = errorInfo + "用户已存在平台管理员,不能同时为CRO管理员!";
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -485,8 +504,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
* @param errorMap 错误信息记录map
|
|
* @param errorMap 错误信息记录map
|
|
* @param currentList 正确结果收集信息
|
|
* @param currentList 正确结果收集信息
|
|
*/
|
|
*/
|
|
- private void checkoutCommonUserDTOInfo(List<CommonUserDTO> commonUserDTOList, HnqzUser
|
|
|
|
- creator, Map<String, String> errorMap, List<UserDTO> currentList) {
|
|
|
|
|
|
+ private void checkoutCommonUserDTOInfo(List<CommonUserDTO> commonUserDTOList, HnqzUser creator, Map<String, String> errorMap, List<UserDTO> currentList) {
|
|
|
|
|
|
// 行编号
|
|
// 行编号
|
|
log.info("开始校验数据:{}", commonUserDTOList);
|
|
log.info("开始校验数据:{}", commonUserDTOList);
|
|
@@ -510,6 +528,37 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
userDTO.setRealname(realName);
|
|
userDTO.setRealname(realName);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 校验用户所属企业
|
|
|
|
+ List<SysDept> list = sysDeptService.list(Wrappers.<SysDept>lambdaQuery().like(SysDept::getName, StrUtil.cleanBlank(commonUserDTO.getEntName())));
|
|
|
|
+ SysDept dept = null;
|
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
|
+ log.error("所属企业不存在");
|
|
|
|
+ errorMap(errorMap, "所属企业不存在", commonUserDTO.getId());
|
|
|
|
+ } else {
|
|
|
|
+ dept = list.get(0);
|
|
|
|
+ userDTO.setDeptId(dept.getDeptId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 校验身份证号
|
|
|
|
+ String idCard = StrUtil.cleanBlank(commonUserDTO.getIdCard());
|
|
|
|
+ if (StrUtil.isBlank(idCard)) {
|
|
|
|
+ log.error("身份证号不存在");
|
|
|
|
+ errorMap(errorMap, "身份证号不存在", commonUserDTO.getId());
|
|
|
|
+ } else {
|
|
|
|
+ if (!Validator.isCitizenId(idCard)) {
|
|
|
|
+ log.error("身份证号格式不正确");
|
|
|
|
+ errorMap(errorMap, "身份证号格式不正确", commonUserDTO.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int count = this.count(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getIdCardNumber, commonUserDTO.getId()));
|
|
|
|
+ if (count != 0) {
|
|
|
|
+ log.error("身份证号格式已经被占用");
|
|
|
|
+ errorMap(errorMap, "身份证号格式已经被占用", commonUserDTO.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ userDTO.setIdCardNumber(idCard);
|
|
|
|
+ }
|
|
|
|
+
|
|
// 校验手机号
|
|
// 校验手机号
|
|
String username = StrUtil.cleanBlank(commonUserDTO.getUsername());
|
|
String username = StrUtil.cleanBlank(commonUserDTO.getUsername());
|
|
if (StringUtils.isEmpty(username)) {
|
|
if (StringUtils.isEmpty(username)) {
|
|
@@ -524,9 +573,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
}
|
|
}
|
|
|
|
|
|
// 校验部门下是否有启用的用户
|
|
// 校验部门下是否有启用的用户
|
|
- int count = count(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username)
|
|
|
|
- .eq(SysUser::getDeptId, creator.getDeptId())
|
|
|
|
- .eq(SysUser::getLockFlag, LockEnum.UN_LOCK.getVal()).eq(SysUser::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
|
|
|
+ int count = count(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
|
|
|
+ // .eq(dept != null, SysUser::getDeptId, dept.getDeptId()));
|
|
if (count != 0) {
|
|
if (count != 0) {
|
|
log.info("手机号被占用");
|
|
log.info("手机号被占用");
|
|
errorMap(errorMap, "手机号被占用", commonUserDTO.getId());
|
|
errorMap(errorMap, "手机号被占用", commonUserDTO.getId());
|
|
@@ -538,7 +586,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
}
|
|
}
|
|
|
|
|
|
// 校验用户角色
|
|
// 校验用户角色
|
|
- SysDept dept = sysDeptService.getById(creator.getDeptId());
|
|
|
|
String roleName = StrUtil.cleanBlank(commonUserDTO.getRoleName());
|
|
String roleName = StrUtil.cleanBlank(commonUserDTO.getRoleName());
|
|
String errInfo = checkoutCommonUserRole(roleName, userDTO, dept);
|
|
String errInfo = checkoutCommonUserRole(roleName, userDTO, dept);
|
|
if (StringUtils.isNotEmpty(errInfo)) {
|
|
if (StringUtils.isNotEmpty(errInfo)) {
|
|
@@ -553,9 +600,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
errorMap(errorMap, "用户状态为空", commonUserDTO.getId());
|
|
errorMap(errorMap, "用户状态为空", commonUserDTO.getId());
|
|
} else {
|
|
} else {
|
|
if (StringUtils.equals(lockFlag, "活跃")) {
|
|
if (StringUtils.equals(lockFlag, "活跃")) {
|
|
- userDTO.setLockFlag("0");
|
|
|
|
|
|
+ userDTO.setLockFlag(CommonConstants.STATUS_NORMAL);
|
|
} else if (StringUtils.equals(lockFlag, "休眠")) {
|
|
} else if (StringUtils.equals(lockFlag, "休眠")) {
|
|
- userDTO.setLockFlag("9");
|
|
|
|
|
|
+ userDTO.setLockFlag(CommonConstants.STATUS_LOCK);
|
|
} else {
|
|
} else {
|
|
log.error("用户状态为值不是\"活跃\"或者\"休眠\"");
|
|
log.error("用户状态为值不是\"活跃\"或者\"休眠\"");
|
|
errorMap(errorMap, "用户状态为值不是\"活跃\"或者\"休眠\"", commonUserDTO.getId());
|
|
errorMap(errorMap, "用户状态为值不是\"活跃\"或者\"休眠\"", commonUserDTO.getId());
|
|
@@ -564,7 +611,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
|
|
|
// 记录正确的结果
|
|
// 记录正确的结果
|
|
userDTO.setCreateTime(LocalDateTime.now());
|
|
userDTO.setCreateTime(LocalDateTime.now());
|
|
- userDTO.setDeptId(dept.getDeptId());
|
|
|
|
|
|
+ userDTO.setUpdateTime(LocalDateTime.now());
|
|
currentList.add(userDTO);
|
|
currentList.add(userDTO);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -630,6 +677,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public UserInfo findUserInfo(SysUser sysUser) {
|
|
public UserInfo findUserInfo(SysUser sysUser) {
|
|
|
|
+
|
|
|
|
+ final String errorKey = "login:error:lock:" + sysUser.getUsername();
|
|
|
|
+ if (Boolean.TRUE.equals(redisTemplate.hasKey(errorKey))) {
|
|
|
|
+ sysUser.setLockFlag(CommonConstants.STATUS_LOCK);
|
|
|
|
+ }
|
|
|
|
+
|
|
UserInfo userInfo = new UserInfo();
|
|
UserInfo userInfo = new UserInfo();
|
|
userInfo.setSysUser(sysUser);
|
|
userInfo.setSysUser(sysUser);
|
|
// 设置角色列表 (ID)
|
|
// 设置角色列表 (ID)
|