|
@@ -30,17 +30,18 @@ import com.qunzhixinxi.hnqz.admin.api.vo.UserVO;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.dto.CommonUserDTO;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.model.input.UserCertificationInput;
|
|
|
import com.qunzhixinxi.hnqz.admin.api.model.excel.CommonUserExcelModel;
|
|
|
-import com.qunzhixinxi.hnqz.admin.api.constant.enums.DelEnum;
|
|
|
import com.qunzhixinxi.hnqz.admin.manager.SysUserManager;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserRoleMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysAreaEntityService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
+import com.qunzhixinxi.hnqz.admin.service.SysRoleService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysUserAreaService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysUserService;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.WmPlatformQuizTestResultService;
|
|
|
import com.qunzhixinxi.hnqz.common.core.constant.CommonConstants;
|
|
|
import com.qunzhixinxi.hnqz.common.core.entity.BaseEntity;
|
|
|
+import com.qunzhixinxi.hnqz.common.core.exception.BizException;
|
|
|
import com.qunzhixinxi.hnqz.common.core.util.R;
|
|
|
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
|
|
|
import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
|
|
@@ -69,10 +70,12 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -99,10 +102,12 @@ public class SysUserController {
|
|
|
private final WmPlatformQuizTestResultService platformQuizTestResultService;
|
|
|
private final SysAreaEntityService areaEntityService;
|
|
|
private final SysUserManager userManager;
|
|
|
+ private final SysRoleService roleService;
|
|
|
|
|
|
private static final List<Integer> SALESMAN_ROLE_ID = ListUtil.of(5, 6);
|
|
|
private static final List<Integer> ADMIN_ROLE_ID = ListUtil.of(1, 2, 7, 19, 27, 34, 35, 44, 45, 46, 47, 48, 49);
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 判断可以登陆的角色
|
|
|
* 只有单纯是5 和 6的角色才不能登陆
|
|
@@ -807,19 +812,19 @@ public class SysUserController {
|
|
|
public R<?> updateUser(@Valid @RequestBody UserDTO userDto) {
|
|
|
|
|
|
|
|
|
- if (CollUtil.containsAny(userDto.getRole(), SALESMAN_ROLE_ID)) {
|
|
|
- return R.failed("当前业务规定不支持修改(全职/兼职)业务员信息");
|
|
|
- }
|
|
|
+ // if (CollUtil.containsAny(userDto.getRole(), SALESMAN_ROLE_ID)) {
|
|
|
+ // return R.failed("当前业务规定不支持修改(全职/兼职)业务员信息");
|
|
|
+ // }
|
|
|
|
|
|
- SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
|
|
|
+ // SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
|
|
|
|
|
|
if (null != userDto.getUserId()) {
|
|
|
|
|
|
SysUser oldData = userService.getById(userDto.getUserId());
|
|
|
|
|
|
- if (StrUtil.isNotBlank(oldData.getRealname()) && StrUtil.isNotBlank(userDto.getRealname()) && !StrUtil.equals(oldData.getRealname(), userDto.getRealname())) {
|
|
|
- return R.failed("用户不能修改姓名");
|
|
|
- }
|
|
|
+ // if (StrUtil.isNotBlank(oldData.getRealname()) && StrUtil.isNotBlank(userDto.getRealname()) && !StrUtil.equals(oldData.getRealname(), userDto.getRealname())) {
|
|
|
+ // return R.failed("用户不能修改姓名");
|
|
|
+ // }
|
|
|
if (StrUtil.isNotBlank(oldData.getIdCardNumber()) && StrUtil.isNotBlank(userDto.getIdCardNumber()) && !StrUtil.equals(oldData.getIdCardNumber(), userDto.getIdCardNumber())) {
|
|
|
return R.failed("用户不能修改身份证号");
|
|
|
}
|
|
@@ -827,180 +832,180 @@ public class SysUserController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {
|
|
|
- if (userDto.getRole().contains(2)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- return R.failed("用户不能同时为平台管理员和药企管理员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(3)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户不能同时为平台管理员和药企管理员");
|
|
|
- }
|
|
|
-
|
|
|
- if (userDto.getDeptId().equals(userVO.getDeptId())) {
|
|
|
- if (sysRole.getRoleId() == 6) {
|
|
|
- return R.failed("用户已存在本机构药企管理员,不能同时为兼职学术推广员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- SysUser query = new SysUser();
|
|
|
- query.setUsername(userDto.getUsername());
|
|
|
- query.setDeptId(userDto.getDeptId());
|
|
|
- SysUser sysUser = sysUserMapper.selectUserByName(query);
|
|
|
- if (sysUser != null) {
|
|
|
- if (sysDept.getLevel() != 2) {
|
|
|
- return R.failed("角色选为药企管理员时,组织架构必须为药企");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(4) || userDto.getRole().contains(37)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户不能同时为平台管理员和经销商管理员");
|
|
|
- }
|
|
|
-
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- return R.failed("用户不能同时为药企管理员和经销商管理员");
|
|
|
- }
|
|
|
- if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 4) {
|
|
|
- return R.failed("用户已存在CSO管理员角色,不能维护为其他经销商组织的CSO管理员角色");
|
|
|
- }
|
|
|
- if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 9) {
|
|
|
- return R.failed("用户已存在CRO管理员角色,不能维护为其他经销商组织的CSO管理员角色");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(9)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户不能同时为平台管理员和CRO管理员");
|
|
|
- }
|
|
|
-
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- return R.failed("用户不能同时为药企管理员和CRO管理员");
|
|
|
- }
|
|
|
- if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 4) {
|
|
|
- return R.failed("用户已存在CSO管理员角色,不能维护为其他经销商组织的CRO管理员角色");
|
|
|
- }
|
|
|
- if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 9) {
|
|
|
- return R.failed("用户已存在CRO管理员角色,不能维护为其他经销商组织的CRO管理员角色");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else if (userDto.getRole().contains(6)) {
|
|
|
- UserDTO userDTO = new UserDTO();
|
|
|
- userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
- List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
- for (UserVO userVO : userDTOList) {
|
|
|
- if (null != userVO.getRoleList()) {
|
|
|
- for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
- if (sysRole.getRoleId() == 2) {
|
|
|
- return R.failed("用户不能同时为平台管理员和兼职学术推广员");
|
|
|
- }
|
|
|
- if (userDto.getDeptId().equals(userVO.getDeptId())) {
|
|
|
- if (sysRole.getRoleId() == 3) {
|
|
|
- return R.failed("用户已存在本药企药企管理员,不能同时为兼职学术推广员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
- if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
|
|
|
- return R.failed("不能跨机构维护学术推广员");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
- if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
|
|
|
- return R.failed("不能跨机构维护学术推广员");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Integer count = sysUserMapper.selectCount(Wrappers.<SysUser>lambdaQuery()
|
|
|
- .eq(SysUser::getUsername, userDto.getUsername())
|
|
|
- .eq(SysUser::getDeptId, userDto.getDeptId())
|
|
|
- .eq(SysUser::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
- if (count > 0) {
|
|
|
- if (userDto.getRole().contains(6) && userDto.getRole().contains(4) || userDto.getRole().contains(37)) {
|
|
|
- return R.failed("用户不能同时为经销商管理员角色和兼职学术推广员角色");
|
|
|
- }
|
|
|
- if (userDto.getRole().contains(7) && userDto.getRole().contains(6)) {
|
|
|
- return R.failed("用户不能同时为财务管理员角色和兼职学术推广员角色");
|
|
|
- }
|
|
|
- if (userDto.getRole().contains(3)) {
|
|
|
- if (sysDept.getLevel() != 2) {
|
|
|
- return R.failed("角色选为药企管理员时,组织架构必须为药企");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 校验身份证上的年龄
|
|
|
- if (StringUtils.isNotEmpty(userDto.getIdCardNumber())) {
|
|
|
- // 获取更新操作的用户角色
|
|
|
- List<Integer> roles = userDto.getRole();
|
|
|
- // 如果角色中包含全职和兼职就需要校验身份证年龄
|
|
|
- if (roles.contains(5) || roles.contains(6)) {
|
|
|
- int ageByIdCard = IdcardUtil.getAgeByIdCard(userDto.getIdCardNumber());
|
|
|
- if (ageByIdCard < 18) {
|
|
|
- return R.failed("年龄未满十八");
|
|
|
- } else if (ageByIdCard > 65) {
|
|
|
- return R.failed("年龄已超过六十五");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // if (SecurityUtils.getRoles().contains(2) || SecurityUtils.getRoles().contains(1)) {
|
|
|
+ // if (userDto.getRole().contains(2)) {
|
|
|
+ // UserDTO userDTO = new UserDTO();
|
|
|
+ // userDTO.setPlatId(userDto.getUsername());
|
|
|
+ // userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
+ // List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ // if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
+ // for (UserVO userVO : userDTOList) {
|
|
|
+ // if (null != userVO.getRoleList()) {
|
|
|
+ // for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ // if (sysRole.getRoleId() == 3) {
|
|
|
+ // return R.failed("用户不能同时为平台管理员和药企管理员");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } else if (userDto.getRole().contains(3)) {
|
|
|
+ // UserDTO userDTO = new UserDTO();
|
|
|
+ // userDTO.setPlatId(userDto.getUsername());
|
|
|
+ // userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
+ // List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ // if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
+ // for (UserVO userVO : userDTOList) {
|
|
|
+ // if (null != userVO.getRoleList()) {
|
|
|
+ // for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ // if (sysRole.getRoleId() == 2) {
|
|
|
+ // return R.failed("用户不能同时为平台管理员和药企管理员");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if (userDto.getDeptId().equals(userVO.getDeptId())) {
|
|
|
+ // if (sysRole.getRoleId() == 6) {
|
|
|
+ // return R.failed("用户已存在本机构药企管理员,不能同时为兼职学术推广员");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // SysUser query = new SysUser();
|
|
|
+ // query.setUsername(userDto.getUsername());
|
|
|
+ // query.setDeptId(userDto.getDeptId());
|
|
|
+ // SysUser sysUser = sysUserMapper.selectUserByName(query);
|
|
|
+ // if (sysUser != null) {
|
|
|
+ // if (sysDept.getLevel() != 2) {
|
|
|
+ // return R.failed("角色选为药企管理员时,组织架构必须为药企");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } else if (userDto.getRole().contains(4) || userDto.getRole().contains(37)) {
|
|
|
+ // UserDTO userDTO = new UserDTO();
|
|
|
+ // userDTO.setPlatId(userDto.getUsername());
|
|
|
+ // userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
+ // List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ // if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
+ // for (UserVO userVO : userDTOList) {
|
|
|
+ // if (null != userVO.getRoleList()) {
|
|
|
+ // for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ // if (sysRole.getRoleId() == 2) {
|
|
|
+ // return R.failed("用户不能同时为平台管理员和经销商管理员");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if (sysRole.getRoleId() == 3) {
|
|
|
+ // return R.failed("用户不能同时为药企管理员和经销商管理员");
|
|
|
+ // }
|
|
|
+ // if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 4) {
|
|
|
+ // return R.failed("用户已存在CSO管理员角色,不能维护为其他经销商组织的CSO管理员角色");
|
|
|
+ // }
|
|
|
+ // if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 9) {
|
|
|
+ // return R.failed("用户已存在CRO管理员角色,不能维护为其他经销商组织的CSO管理员角色");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } else if (userDto.getRole().contains(9)) {
|
|
|
+ // UserDTO userDTO = new UserDTO();
|
|
|
+ // userDTO.setPlatId(userDto.getUsername());
|
|
|
+ // userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
+ // List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ // if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
+ // for (UserVO userVO : userDTOList) {
|
|
|
+ // if (null != userVO.getRoleList()) {
|
|
|
+ // for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ // if (sysRole.getRoleId() == 2) {
|
|
|
+ // return R.failed("用户不能同时为平台管理员和CRO管理员");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // if (sysRole.getRoleId() == 3) {
|
|
|
+ // return R.failed("用户不能同时为药企管理员和CRO管理员");
|
|
|
+ // }
|
|
|
+ // if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 4) {
|
|
|
+ // return R.failed("用户已存在CSO管理员角色,不能维护为其他经销商组织的CRO管理员角色");
|
|
|
+ // }
|
|
|
+ // if (!userDto.getUserId().equals(userVO.getUserId()) && sysRole.getRoleId() == 9) {
|
|
|
+ // return R.failed("用户已存在CRO管理员角色,不能维护为其他经销商组织的CRO管理员角色");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } else if (userDto.getRole().contains(6)) {
|
|
|
+ // UserDTO userDTO = new UserDTO();
|
|
|
+ // userDTO.setPlatId(userDto.getUsername());
|
|
|
+ // userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
+ // List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
+ // if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
+ // for (UserVO userVO : userDTOList) {
|
|
|
+ // if (null != userVO.getRoleList()) {
|
|
|
+ // for (SysRole sysRole : userVO.getRoleList()) {
|
|
|
+ // if (sysRole.getRoleId() == 2) {
|
|
|
+ // return R.failed("用户不能同时为平台管理员和兼职学术推广员");
|
|
|
+ // }
|
|
|
+ // if (userDto.getDeptId().equals(userVO.getDeptId())) {
|
|
|
+ // if (sysRole.getRoleId() == 3) {
|
|
|
+ // return R.failed("用户已存在本药企药企管理员,不能同时为兼职学术推广员");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } else {
|
|
|
+ // if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
+ // if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
|
|
|
+ // return R.failed("不能跨机构维护学术推广员");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // } else {
|
|
|
+ // if (!userDto.getDeptId().equals(SecurityUtils.getUser().getDeptId())) {
|
|
|
+ // if (userDto.getRole().contains(5) || userDto.getRole().contains(6)) {
|
|
|
+ // return R.failed("不能跨机构维护学术推广员");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // Integer count = sysUserMapper.selectCount(Wrappers.<SysUser>lambdaQuery()
|
|
|
+ // .eq(SysUser::getUsername, userDto.getUsername())
|
|
|
+ // .eq(SysUser::getDeptId, userDto.getDeptId())
|
|
|
+ // .eq(SysUser::getDelFlag, DelEnum.NOT_DEL.getVal()));
|
|
|
+ // if (count > 0) {
|
|
|
+ // if (CollUtil.containsAll(userDto.getRole(), ListUtil.of(6, 37))) {
|
|
|
+ // return R.failed("用户不能同时为经销商管理员角色和兼职学术推广员角色");
|
|
|
+ // }
|
|
|
+ // if (userDto.getRole().contains(7) && userDto.getRole().contains(6)) {
|
|
|
+ // return R.failed("用户不能同时为财务管理员角色和兼职学术推广员角色");
|
|
|
+ // }
|
|
|
+ // if (userDto.getRole().contains(3)) {
|
|
|
+ // if (sysDept.getLevel() != 2) {
|
|
|
+ // return R.failed("角色选为药企管理员时,组织架构必须为药企");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // // 校验身份证上的年龄
|
|
|
+ // if (StringUtils.isNotEmpty(userDto.getIdCardNumber())) {
|
|
|
+ // // 获取更新操作的用户角色
|
|
|
+ // List<Integer> roles = userDto.getRole();
|
|
|
+ // // 如果角色中包含全职和兼职就需要校验身份证年龄
|
|
|
+ // if (roles.contains(5) || roles.contains(6)) {
|
|
|
+ // int ageByIdCard = IdcardUtil.getAgeByIdCard(userDto.getIdCardNumber());
|
|
|
+ // if (ageByIdCard < 18) {
|
|
|
+ // return R.failed("年龄未满十八");
|
|
|
+ // } else if (ageByIdCard > 65) {
|
|
|
+ // return R.failed("年龄已超过六十五");
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
return R.ok(userService.updateUser(userDto));
|
|
|
}
|
|
@@ -1024,7 +1029,7 @@ public class SysUserController {
|
|
|
* @param userDTO 查询参数列表
|
|
|
* @return 用户集合
|
|
|
*/
|
|
|
- @PostMapping(value = "/selectUserList")
|
|
|
+ // @PostMapping(value = "/selectUserList")
|
|
|
public R<?> selectUserList(@RequestBody UserDTO userDTO) {
|
|
|
|
|
|
HnqzUser user = SecurityUtils.getUser();
|
|
@@ -1083,6 +1088,116 @@ public class SysUserController {
|
|
|
return R.ok(userVosPage);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 分页查询用户
|
|
|
+ *
|
|
|
+ * @param query 查询参数列表
|
|
|
+ * @return 用户集合
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/selectUserList")
|
|
|
+ public R<?> pageUsers(@Validated @RequestBody SysUserDTO.OnPage query) {
|
|
|
+
|
|
|
+
|
|
|
+ // 获取全部的可用角色
|
|
|
+ Map<Integer, SysRole> roleId2RoleMap = roleService.list().stream().collect(Collectors.toMap(SysRole::getRoleId, Function.identity()));
|
|
|
+
|
|
|
+
|
|
|
+ // 操作人
|
|
|
+ HnqzUser user = SecurityUtils.getUser();
|
|
|
+
|
|
|
+ // 获取操作人的角色
|
|
|
+ Set<Integer> operatorRoleIds = new HashSet<>(SecurityUtils.getRoles());
|
|
|
+
|
|
|
+
|
|
|
+ Set<Integer> targetRoleIds = new HashSet<>();
|
|
|
+
|
|
|
+
|
|
|
+ SysRole role = null;
|
|
|
+
|
|
|
+ // 系统管理员
|
|
|
+ if (operatorRoleIds.contains(1)) {
|
|
|
+ role = roleId2RoleMap.get(1);
|
|
|
+ }
|
|
|
+ // 中生平台管理员
|
|
|
+ else if (operatorRoleIds.contains(2)) {
|
|
|
+ role = roleId2RoleMap.get(2);
|
|
|
+ }
|
|
|
+ // 事业部系统管理员
|
|
|
+ else if (operatorRoleIds.contains(50)) {
|
|
|
+ role = roleId2RoleMap.get(50);
|
|
|
+ }
|
|
|
+ // 运营管理员
|
|
|
+ else if (operatorRoleIds.contains(3)) {
|
|
|
+ role = roleId2RoleMap.get(3);
|
|
|
+ }
|
|
|
+ // 区域管理员
|
|
|
+ else if (operatorRoleIds.contains(4)) {
|
|
|
+ role = roleId2RoleMap.get(4);
|
|
|
+ }
|
|
|
+ // 服务商管理员
|
|
|
+ else if (operatorRoleIds.contains(37)) {
|
|
|
+ role = roleId2RoleMap.get(37);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (role == null){
|
|
|
+ throw new BizException("当前用户角色不可用");
|
|
|
+ } else {
|
|
|
+ String visible = role.getVisible();
|
|
|
+ if (StrUtil.isBlank(visible)) {
|
|
|
+ throw new BizException("当前角色未配置查询角色");
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Integer> visibles = Arrays.stream(visible.split(StrUtil.COMMA)).mapToInt(Integer::valueOf).boxed().collect(Collectors.toSet());
|
|
|
+
|
|
|
+ Integer targetRoleId = query.getRoleId();
|
|
|
+
|
|
|
+ if (targetRoleId == null){
|
|
|
+ targetRoleIds.addAll(visibles);
|
|
|
+ } else if (visibles.contains(targetRoleId)) {
|
|
|
+ targetRoleIds.add(targetRoleId);
|
|
|
+ } else {
|
|
|
+ throw new BizException("当前角色禁止查看其他角色");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ query.setFinalQueryRoleIds(targetRoleIds);
|
|
|
+
|
|
|
+ Page<SysUser> userVosPage = userService.pageUser(query, SecurityUtils.getUser());
|
|
|
+
|
|
|
+
|
|
|
+ // Set<Integer> userIds = userVosPage.getRecords().stream().map(UserVO::getUserId).collect(Collectors.toSet());
|
|
|
+ //
|
|
|
+ // if (CollUtil.isNotEmpty(userIds)) {
|
|
|
+ //
|
|
|
+ // List<WmPlatformQuizTestResult> quizTestResults = platformQuizTestResultService.listPltQuizResults(userIds);
|
|
|
+ //
|
|
|
+ // LocalDate today = LocalDate.now();
|
|
|
+ // Map<Integer, List<WmPlatformQuizTestResult>> quizTestResult = quizTestResults.stream().filter(res -> res.getExpiry().isAfter(today)).collect(Collectors.groupingBy(WmPlatformQuizTestResult::getUserId));
|
|
|
+ //
|
|
|
+ // userVosPage.getRecords().forEach(vo -> {
|
|
|
+ // List<WmPlatformQuizTestResult> testResults = quizTestResult.get(vo.getUserId());
|
|
|
+ // List<WmQuizResultModel> pure = null;
|
|
|
+ // if (CollUtil.isNotEmpty(testResults)) {
|
|
|
+ // Map<Integer, List<WmPlatformQuizTestResult>> collect = testResults.stream().collect(Collectors.groupingBy(WmPlatformQuizTestResult::getQuizId));
|
|
|
+ // pure = new ArrayList<>(collect.size());
|
|
|
+ //
|
|
|
+ // for (Map.Entry<Integer, List<WmPlatformQuizTestResult>> entry : collect.entrySet()) {
|
|
|
+ // pure.add(entry.getValue().get(0).getQuizResult());
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // vo.setQuizResult(CollUtil.isEmpty(pure) ? Collections.emptyList() : pure);
|
|
|
+ //
|
|
|
+ // // 所属区域
|
|
|
+ // List<Long> areaCodes = userAreaService.listUserAreas(Long.valueOf(vo.getUserId()));
|
|
|
+ // vo.setAreaCodes(areaCodes);
|
|
|
+ //
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ return R.ok(userVosPage);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改个人信息
|
|
|
*
|