|
|
@@ -1,8 +1,6 @@
|
|
|
package com.ydtech.modules.admin.controller;
|
|
|
|
|
|
|
|
|
-import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@@ -15,11 +13,8 @@ import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.admin.model.*;
|
|
|
import com.ydtech.modules.admin.model.dto.AgentUserDto;
|
|
|
import com.ydtech.modules.admin.model.dto.SysUserDto;
|
|
|
-import com.ydtech.modules.admin.model.vo.SysReferrerVo;
|
|
|
-import com.ydtech.modules.admin.model.vo.SysUserVO;
|
|
|
+import com.ydtech.modules.admin.model.vo.*;
|
|
|
import com.ydtech.modules.admin.service.*;
|
|
|
-import com.ydtech.modules.admin.model.vo.SysUserBaseVO;
|
|
|
-import com.ydtech.modules.admin.model.vo.SysUser2Vo;
|
|
|
import com.ydtech.modules.base.controller.BaseController;
|
|
|
import com.ydtech.modules.base.model.dto.BaseDto;
|
|
|
import com.ydtech.modules.base.model.dto.PageDto;
|
|
|
@@ -30,9 +25,11 @@ import com.ydtech.security.utils.PasswordUtils;
|
|
|
import com.ydtech.utils.StringUtils;
|
|
|
import com.ydtech.utils.excel.ExcelEasypoiUtils;
|
|
|
import com.ydtech.utils.idgen.IdGenerate;
|
|
|
-import io.swagger.annotations.*;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -40,13 +37,10 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-import static com.ydtech.constants.RedisConstant.PHONE_VERIFICATION_CODE_KEY;
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 用户控制器
|
|
|
@@ -57,23 +51,20 @@ import static com.ydtech.constants.RedisConstant.PHONE_VERIFICATION_CODE_KEY;
|
|
|
@RestController
|
|
|
@Api(tags = "用户控制器")
|
|
|
@RequestMapping("user")
|
|
|
+@RequiredArgsConstructor
|
|
|
public class SysUserController extends BaseController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private SysUserService sysUserService;
|
|
|
- @Autowired
|
|
|
- private SysUserRoleService sysUserRoleService;
|
|
|
- @Autowired
|
|
|
- private SysDeptService sysDeptService;
|
|
|
- @Autowired
|
|
|
- private SysUserInfoService sysUserInfoService;
|
|
|
+ private final SysUserService sysUserService;
|
|
|
+
|
|
|
+ private final SysUserRoleService sysUserRoleService;
|
|
|
+
|
|
|
+ private final SysDeptService sysDeptService;
|
|
|
+
|
|
|
+ private final SysUserInfoService sysUserInfoService;
|
|
|
+
|
|
|
+ private final EsmUserReferrerService esmUserReferrerService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private StringRedisTemplate stringRedisTemplate;
|
|
|
- @Autowired
|
|
|
- private EsmUserReferrerService esmUserReferrerService;
|
|
|
- @Autowired
|
|
|
- private SysRoleService sysRoleService;
|
|
|
+ private final SysRoleService sysRoleService;
|
|
|
|
|
|
|
|
|
// @PreAuthorize("hasAuthority('sys:user:delete')")
|
|
|
@@ -111,6 +102,7 @@ public class SysUserController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 用户角色分页查询
|
|
|
+ *
|
|
|
* @param pageRequest
|
|
|
* @return
|
|
|
*/
|
|
|
@@ -125,7 +117,7 @@ public class SysUserController extends BaseController {
|
|
|
sysUser.setName(name);
|
|
|
sysUser.setMobile(mobile);
|
|
|
Page page = PageRequest.buildPageRequest(pageRequest);
|
|
|
- IPage<SysUser> pResult = sysUserService.selectUserPage(page,sysUser,containsSubDept);
|
|
|
+ IPage<SysUser> pResult = sysUserService.selectUserPage(page, sysUser, containsSubDept);
|
|
|
//传入查询条件
|
|
|
PageResult pageResult = PageResult.buildPageResult(pResult);
|
|
|
return HttpResult.ok(pageResult);
|
|
|
@@ -408,7 +400,7 @@ public class SysUserController extends BaseController {
|
|
|
// 查询角色
|
|
|
SysUserRole sysUserRole = sysUserRoleService.selectByUserId(userId);
|
|
|
// SysUserRole sysUserRole = sysUserRoleService.getById(userId);
|
|
|
- if (!ObjectUtils.isEmpty(sysUserRole)){
|
|
|
+ if (!ObjectUtils.isEmpty(sysUserRole)) {
|
|
|
sysUser.setRoleId(StringUtils.toString(sysUserRole.getRoleId()));
|
|
|
}
|
|
|
// 查询推荐人
|
|
|
@@ -423,10 +415,11 @@ public class SysUserController extends BaseController {
|
|
|
//查询详情信息
|
|
|
SysUserInfo userInfo = sysUserInfoService.getById(userId);
|
|
|
|
|
|
- SysUser2Vo sysUserVo = new SysUser2Vo();
|
|
|
- sysUserVo.setSysUser(sysUser);
|
|
|
+ SysUserInfoQuery sysUserVo = new SysUserInfoQuery();
|
|
|
|
|
|
+ sysUserVo.setSysUser(sysUser);
|
|
|
sysUserVo.setSysUserInfo(userInfo);
|
|
|
+
|
|
|
return HttpResult.ok(sysUserVo);
|
|
|
|
|
|
}
|
|
|
@@ -447,7 +440,7 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
EsmUserReferrer eur = esmUserReferrerService.getById(sysUser.getId());
|
|
|
- if(null != eur){
|
|
|
+ if (null != eur) {
|
|
|
sysUser.setReferrerId(eur.getReferrerId());
|
|
|
sysUser.setReferrerName(eur.getReferrerName());
|
|
|
}
|
|
|
@@ -480,9 +473,9 @@ public class SysUserController extends BaseController {
|
|
|
return HttpResult.error("推荐人信息不存在");
|
|
|
}
|
|
|
//只有团队长和代理人才能邀请 by gws
|
|
|
- SysUserRole recommenderRole =sysUserRoleService.selectByUserId(recommenderid);
|
|
|
+ SysUserRole recommenderRole = sysUserRoleService.selectByUserId(recommenderid);
|
|
|
|
|
|
- if(!"20".equals(recommenderRole.getRoleId().toString()) && !"21".equals(recommenderRole.getRoleId().toString())){
|
|
|
+ if (!"20".equals(recommenderRole.getRoleId().toString()) && !"21".equals(recommenderRole.getRoleId().toString())) {
|
|
|
return HttpResult.error("只有团队长和代理人才能邀请");
|
|
|
}
|
|
|
|
|
|
@@ -522,7 +515,7 @@ public class SysUserController extends BaseController {
|
|
|
userRole.setRoleId(20L);
|
|
|
sysUserRoleService.save(userRole);
|
|
|
|
|
|
- esmUserReferrerService.addReferrer(dto.getReferrerId(),nextPK);
|
|
|
+ esmUserReferrerService.addReferrer(dto.getReferrerId(), nextPK);
|
|
|
|
|
|
return HttpResult.ok("保存成功", sysUser.getId());
|
|
|
}
|
|
|
@@ -588,32 +581,32 @@ public class SysUserController extends BaseController {
|
|
|
//by gws 21 团队长 20 代理人 必须归属团队
|
|
|
// 22 后线人员 必须归属部门
|
|
|
if (StringUtils.isNullOrEmpty(a.getRoleId())) throw new SystemException("角色ID不能为空");
|
|
|
- if("21".equals(a.getRoleId())||"20".equals(a.getRoleId())){//21 团队长 20 代理人
|
|
|
- boolean teamflag=false;
|
|
|
- char[] deptids=a.getDeptId().toCharArray();
|
|
|
+ if ("21".equals(a.getRoleId()) || "20".equals(a.getRoleId())) {//21 团队长 20 代理人
|
|
|
+ boolean teamflag = false;
|
|
|
+ char[] deptids = a.getDeptId().toCharArray();
|
|
|
char ch1 = 'D';
|
|
|
char ch2 = 'M';
|
|
|
- if(deptids.length>6){
|
|
|
- teamflag=deptids[deptids.length-3]==ch1&&deptids[deptids.length-6]==ch2;
|
|
|
+ if (deptids.length > 6) {
|
|
|
+ teamflag = deptids[deptids.length - 3] == ch1 && deptids[deptids.length - 6] == ch2;
|
|
|
}
|
|
|
- if(!teamflag){
|
|
|
- throw new SystemException("团队长和代理人只能归属团队中") ;
|
|
|
+ if (!teamflag) {
|
|
|
+ throw new SystemException("团队长和代理人只能归属团队中");
|
|
|
}
|
|
|
- }else if("22".equals(a.getRoleId())){//22 后线人员
|
|
|
- boolean deptflag=false;
|
|
|
- char[] deptids=a.getDeptId().toCharArray();
|
|
|
+ } else if ("22".equals(a.getRoleId())) {//22 后线人员
|
|
|
+ boolean deptflag = false;
|
|
|
+ char[] deptids = a.getDeptId().toCharArray();
|
|
|
char ch1 = 'D';
|
|
|
char ch2 = 'M';
|
|
|
- if(deptids.length>6){
|
|
|
- deptflag=deptids[deptids.length-3]==ch1&&deptids[deptids.length-6]!=ch2;
|
|
|
- }else if(deptids.length<=6 && deptids.length>3){
|
|
|
- deptflag=deptids[deptids.length-3]==ch1;
|
|
|
+ if (deptids.length > 6) {
|
|
|
+ deptflag = deptids[deptids.length - 3] == ch1 && deptids[deptids.length - 6] != ch2;
|
|
|
+ } else if (deptids.length <= 6 && deptids.length > 3) {
|
|
|
+ deptflag = deptids[deptids.length - 3] == ch1;
|
|
|
}
|
|
|
- if(!deptflag){
|
|
|
- throw new SystemException("后线人员只能归属业务部门中") ;
|
|
|
+ if (!deptflag) {
|
|
|
+ throw new SystemException("后线人员只能归属业务部门中");
|
|
|
}
|
|
|
- }else{
|
|
|
- throw new SystemException("角色id有误") ;
|
|
|
+ } else {
|
|
|
+ throw new SystemException("角色id有误");
|
|
|
}
|
|
|
sysUserService.saveUser(a);
|
|
|
|
|
|
@@ -650,11 +643,11 @@ public class SysUserController extends BaseController {
|
|
|
@ApiOperation(value = "保存用户基本详情信息")
|
|
|
@Transactional
|
|
|
@PostMapping(value = "/saveUserInfo")
|
|
|
- public HttpResult saveUserInfo(@RequestBody SysUser2Vo sysUserVo){
|
|
|
+ public HttpResult saveUserInfo(@RequestBody SysUser2Vo sysUserVo) {
|
|
|
|
|
|
//by gws 21 团队长 20 代理人 必须归属团队
|
|
|
// 22 后线人员 必须归属部门
|
|
|
- SysUser sysUser=sysUserVo.getSysUser();
|
|
|
+ SysUser sysUser = sysUserVo.getSysUser();
|
|
|
if (StringUtils.isNullOrEmpty(sysUser)) {
|
|
|
return HttpResult.error("用户信息不能为空");
|
|
|
}
|
|
|
@@ -662,39 +655,39 @@ public class SysUserController extends BaseController {
|
|
|
return HttpResult.error("机构ID不能为空");
|
|
|
}
|
|
|
if (StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
|
|
|
- throw new SystemException("角色id不能为空") ;
|
|
|
+ throw new SystemException("角色id不能为空");
|
|
|
}
|
|
|
if (!StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
|
|
|
- if("21".equals(sysUser.getRoleId())||"20".equals(sysUser.getRoleId())){//21 团队长 20 代理人
|
|
|
- boolean teamflag=false;
|
|
|
- char[] deptids=sysUser.getDeptId().toCharArray();
|
|
|
+ if ("21".equals(sysUser.getRoleId()) || "20".equals(sysUser.getRoleId())) {//21 团队长 20 代理人
|
|
|
+ boolean teamflag = false;
|
|
|
+ char[] deptids = sysUser.getDeptId().toCharArray();
|
|
|
char ch1 = 'D';
|
|
|
char ch2 = 'M';
|
|
|
- if(deptids.length>6){
|
|
|
- teamflag=deptids[deptids.length-3]==ch1&&deptids[deptids.length-6]==ch2;
|
|
|
+ if (deptids.length > 6) {
|
|
|
+ teamflag = deptids[deptids.length - 3] == ch1 && deptids[deptids.length - 6] == ch2;
|
|
|
}
|
|
|
- if(!teamflag){
|
|
|
- throw new SystemException("团队长和代理人只能归属团队中") ;
|
|
|
+ if (!teamflag) {
|
|
|
+ throw new SystemException("团队长和代理人只能归属团队中");
|
|
|
}
|
|
|
- }else if("22".equals(sysUser.getRoleId())){//22 后线人员
|
|
|
- boolean deptflag=false;
|
|
|
- char[] deptids=sysUser.getDeptId().toCharArray();
|
|
|
+ } else if ("22".equals(sysUser.getRoleId())) {//22 后线人员
|
|
|
+ boolean deptflag = false;
|
|
|
+ char[] deptids = sysUser.getDeptId().toCharArray();
|
|
|
char ch1 = 'D';
|
|
|
char ch2 = 'M';
|
|
|
- if(deptids.length>6){
|
|
|
- deptflag=deptids[deptids.length-3]==ch1&&deptids[deptids.length-6]!=ch2;
|
|
|
- }else if(deptids.length<=6 && deptids.length>3){
|
|
|
- deptflag=deptids[deptids.length-3]==ch1;
|
|
|
+ if (deptids.length > 6) {
|
|
|
+ deptflag = deptids[deptids.length - 3] == ch1 && deptids[deptids.length - 6] != ch2;
|
|
|
+ } else if (deptids.length > 3) {
|
|
|
+ deptflag = deptids[deptids.length - 3] == ch1;
|
|
|
}
|
|
|
- if(!deptflag){
|
|
|
- throw new SystemException("后线人员只能归属业务部门中") ;
|
|
|
+ if (!deptflag) {
|
|
|
+ throw new SystemException("后线人员只能归属业务部门中");
|
|
|
}
|
|
|
- }else{
|
|
|
- throw new SystemException("角色id有误") ;
|
|
|
+ } else {
|
|
|
+ throw new SystemException("角色id有误");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- return HttpResult.ok(sysUserService.saveUserInfo(sysUserVo)) ;
|
|
|
+ return HttpResult.ok(sysUserService.saveUserInfo(sysUserVo));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -704,8 +697,8 @@ public class SysUserController extends BaseController {
|
|
|
@ApiImplicitParam(name = "userId", value = "用户信息", required = true, dataType = "String")
|
|
|
})
|
|
|
@Transactional
|
|
|
- public HttpResult updateUserInfo(@PathVariable String userId,@RequestBody SysUser2Vo sysUserVo) {
|
|
|
- return HttpResult.ok(sysUserService.updateUserInfo(userId,sysUserVo));
|
|
|
+ public HttpResult updateUserInfo(@PathVariable String userId, @RequestBody SysUser2Vo sysUserVo) {
|
|
|
+ return HttpResult.ok(sysUserService.updateUserInfo(userId, sysUserVo));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -719,7 +712,7 @@ public class SysUserController extends BaseController {
|
|
|
@PostMapping(value = "/realNameAuth")
|
|
|
@ApiOperation(value = "实名认证", notes = "" +
|
|
|
"参数1:姓名" +
|
|
|
- "</br>参数2:身份证号" )
|
|
|
+ "</br>参数2:身份证号")
|
|
|
public HttpResult realNameAuth(@RequestBody BaseDto dto) {
|
|
|
SysUser sysUser = sysUserService.getById(getUserId());
|
|
|
sysUser.setName(dto.getParam1());
|