|
@@ -1,7 +1,6 @@
|
|
|
package com.qunzhixinxi.hnqz.admin.controller;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.util.ArrayUtil;
|
|
|
import cn.hutool.core.util.IdcardUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
@@ -32,9 +31,11 @@ import com.qunzhixinxi.hnqz.admin.mapper.SysCsmUserRelationMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.mapper.SysUserRoleMapper;
|
|
|
import com.qunzhixinxi.hnqz.admin.service.SysDeptService;
|
|
|
+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.util.R;
|
|
|
import com.qunzhixinxi.hnqz.common.log.annotation.SysLog;
|
|
|
import com.qunzhixinxi.hnqz.common.security.annotation.Inner;
|
|
@@ -45,6 +46,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -52,6 +54,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
@@ -85,6 +88,7 @@ public class SysUserController {
|
|
|
private final SysUserRoleMapper sysUserRoleMapper;
|
|
|
private final WmPlatformQuizTestResultService platformQuizTestResultService;
|
|
|
private final SysCsmUserRelationMapper sysCsmUserRelationMapper;
|
|
|
+ private final SysUserAreaService userAreaService;
|
|
|
|
|
|
|
|
|
private boolean isZbOrDbUsers(Integer[] roles) {
|
|
@@ -111,12 +115,12 @@ public class SysUserController {
|
|
|
/**
|
|
|
* 用户管理-认证
|
|
|
*
|
|
|
- * @param input
|
|
|
+ * @param input 输入信息
|
|
|
* @return R
|
|
|
*/
|
|
|
@SysLog("用户管理-认证")
|
|
|
@GetMapping("/getAuthInfo")
|
|
|
- public R getAuthInfo(UserCertificationInput input) {
|
|
|
+ public R<?> getAuthInfo(UserCertificationInput input) {
|
|
|
//参数校验
|
|
|
return userService.getAuthInfo(input);
|
|
|
}
|
|
@@ -129,7 +133,7 @@ public class SysUserController {
|
|
|
*/
|
|
|
@Inner
|
|
|
@GetMapping("/info/{username}")
|
|
|
- public R info(@PathVariable String username) {
|
|
|
+ public R<?> info(@PathVariable String username) {
|
|
|
|
|
|
boolean b = username.endsWith("@mp");
|
|
|
if (b) {
|
|
@@ -168,9 +172,9 @@ public class SysUserController {
|
|
|
}
|
|
|
String password = redisTemplate.opsForValue().get(username) + "";
|
|
|
if (null != password) {
|
|
|
- for (int i = 0; i < user.size(); i++) {
|
|
|
- UserInfo userInfo = userService.findUserInfo(user.get(i));
|
|
|
- if (Md5Utils.getMD5(password.getBytes()).equals(user.get(i).getW1())) {
|
|
|
+ for (SysUser sysUser : user) {
|
|
|
+ UserInfo userInfo = userService.findUserInfo(sysUser);
|
|
|
+ if (Md5Utils.getMD5(password.getBytes()).equals(sysUser.getW1())) {
|
|
|
if (isZbOrDbUsers(userInfo.getRoles())) {
|
|
|
redisTemplate.delete(username);
|
|
|
return R.ok(userInfo);
|
|
@@ -189,7 +193,7 @@ public class SysUserController {
|
|
|
* @return 用户信息
|
|
|
*/
|
|
|
@GetMapping("/{id}")
|
|
|
- public R user(@PathVariable Integer id) {
|
|
|
+ public R<?> user(@PathVariable Integer id) {
|
|
|
return R.ok(userService.selectUserVoById(id));
|
|
|
}
|
|
|
|
|
@@ -197,30 +201,37 @@ public class SysUserController {
|
|
|
* 根据用户名查询用户信息
|
|
|
*
|
|
|
* @param username 用户名
|
|
|
- * @return
|
|
|
+ * @return 用户详情
|
|
|
*/
|
|
|
@GetMapping("/details/{username}")
|
|
|
- public R user(@PathVariable String username) {
|
|
|
- SysUser condition = new SysUser();
|
|
|
- condition.setUsername(username);
|
|
|
- return R.ok(userService.getOne(new QueryWrapper<>(condition)));
|
|
|
+ public R<SysUser> user(@PathVariable String username) {
|
|
|
+
|
|
|
+ SysUser one = userService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username));
|
|
|
+ if (one != null) {
|
|
|
+ List<Long> areaCodes = userAreaService.listUserAreas(Long.valueOf(one.getUserId()));
|
|
|
+ one.setAreaCodes(areaCodes);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(one);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据用户名查询用户信息
|
|
|
*
|
|
|
* @param username 用户名
|
|
|
- * @return
|
|
|
+ * @return 用户信息
|
|
|
*/
|
|
|
@GetMapping("/getDetails")
|
|
|
- public R getuser(String deptId, String username) {
|
|
|
- SysUser condition = new SysUser();
|
|
|
- condition.setUsername(username);
|
|
|
- SysDept sysDept1 = sysDeptService.getById(Integer.parseInt(deptId));
|
|
|
- if (null != sysDept1) {
|
|
|
- condition.setDeptId(sysDept1.getDeptId());
|
|
|
+ public R<SysUser> getuser(@RequestParam(value = "deptId") Integer deptId,
|
|
|
+ @RequestParam(value = "username") String username) {
|
|
|
+
|
|
|
+ SysUser one = userService.getOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, username).eq(SysUser::getDeptId, deptId));
|
|
|
+ if (one != null) {
|
|
|
+ List<Long> areaCodes = userAreaService.listUserAreas(Long.valueOf(one.getUserId()));
|
|
|
+ one.setAreaCodes(areaCodes);
|
|
|
}
|
|
|
- return R.ok(userService.getOne(new QueryWrapper<>(condition)));
|
|
|
+
|
|
|
+ return R.ok(one);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -232,7 +243,7 @@ public class SysUserController {
|
|
|
@SysLog("删除用户信息")
|
|
|
@DeleteMapping("/{id}")
|
|
|
@PreAuthorize("@pms.hasPermission('sys_user_del')")
|
|
|
- public R userDel(@PathVariable Integer id) {
|
|
|
+ public R<Boolean> userDel(@PathVariable Integer id) {
|
|
|
SysUser sysUser = userService.getById(id);
|
|
|
return R.ok(userService.deleteUserById(sysUser));
|
|
|
}
|
|
@@ -246,7 +257,7 @@ public class SysUserController {
|
|
|
@Inner(value = false)
|
|
|
@SysLog("修改密码")
|
|
|
@PostMapping("/upd")
|
|
|
- public R updatePwd(@RequestBody @Valid UserPwd userPwd) {
|
|
|
+ public R<?> updatePwd(@RequestBody @Valid UserPwd userPwd) {
|
|
|
|
|
|
return userService.updatePwd(userPwd);
|
|
|
}
|
|
@@ -260,7 +271,7 @@ public class SysUserController {
|
|
|
@SysLog("添加用户")
|
|
|
@PostMapping
|
|
|
@PreAuthorize("@pms.hasPermission('sys_user_add')")
|
|
|
- public R user(@RequestBody UserDTO userDto) {
|
|
|
+ public R<Boolean> user(@Validated(value = BaseEntity.Create.class) @RequestBody UserDTO userDto) {
|
|
|
|
|
|
// 姓名去除空格(包括字符之间的所有空格都会去除)
|
|
|
userDto.setRealname(StrUtil.cleanBlank(userDto.getRealname()));
|
|
@@ -280,9 +291,10 @@ public class SysUserController {
|
|
|
if (userDto.getRole().contains(2)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -343,9 +355,9 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(4)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -392,9 +404,9 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(7)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -414,9 +426,9 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(5)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -443,9 +455,9 @@ public class SysUserController {
|
|
|
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -455,9 +467,9 @@ public class SysUserController {
|
|
|
SysUserRole sysUserRole = new SysUserRole();
|
|
|
sysUserRole.setUserId(userVO.getUserId());
|
|
|
List<SysUserRole> sysUserRoleList = sysUserRoleMapper.selectById(sysUserRole);
|
|
|
- for (int i = 0; i < sysUserRoleList.size(); i++) {
|
|
|
- if (sysUserRoleList.get(i).getRoleId().equals(7)) {
|
|
|
- SysUser sysUser = userService.getById(sysUserRoleList.get(i).getUserId());
|
|
|
+ for (SysUserRole userRole : sysUserRoleList) {
|
|
|
+ if (userRole.getRoleId().equals(7)) {
|
|
|
+ SysUser sysUser = userService.getById(userRole.getUserId());
|
|
|
if (sysUser.getDeptId().equals(userDto.getDeptId())) {
|
|
|
return R.failed("用户已存在财务管理员角色,不能同时为兼职学术推广员");
|
|
|
}
|
|
@@ -471,9 +483,9 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(9)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -497,7 +509,7 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(31)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setUsername(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = sysUserMapper.selectByPhone(userDTO);
|
|
|
if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
@@ -615,7 +627,7 @@ public class SysUserController {
|
|
|
@SysLog("更新用户信息")
|
|
|
@PutMapping
|
|
|
@PreAuthorize("@pms.hasPermission('sys_user_edit')")
|
|
|
- public R updateUser(@Valid @RequestBody UserDTO userDto) {
|
|
|
+ public R<?> updateUser(@Valid @RequestBody UserDTO userDto) {
|
|
|
|
|
|
// qcc调用企查查查询是否为主要人员
|
|
|
SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
|
|
@@ -715,9 +727,9 @@ public class SysUserController {
|
|
|
if (userDto.getRole().contains(2)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -732,9 +744,9 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(3)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -764,9 +776,9 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(4)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -791,9 +803,9 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(9)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|
|
@@ -818,9 +830,9 @@ public class SysUserController {
|
|
|
} else if (userDto.getRole().contains(6)) {
|
|
|
UserDTO userDTO = new UserDTO();
|
|
|
userDTO.setPlatId(userDto.getUsername());
|
|
|
- userDTO.setDelFlag("0");
|
|
|
+ userDTO.setDelFlag(CommonConstants.STATUS_NORMAL);
|
|
|
List<UserVO> userDTOList = userService.getUserVoByPlatId(userDTO);
|
|
|
- if (userDTOList.size() > 0) {
|
|
|
+ if (CollUtil.isNotEmpty(userDTOList)) {
|
|
|
for (UserVO userVO : userDTOList) {
|
|
|
if (null != userVO.getRoleList()) {
|
|
|
for (SysRole sysRole : userVO.getRoleList()) {
|