Ver Fonte

人员模块增加校验-团队长(代理人)归属团队、后线归属部门

guoweisong há 2 anos atrás
pai
commit
feeaaa5316

+ 78 - 2
src/main/java/com/ydtech/modules/admin/controller/SysUserController.java

@@ -492,7 +492,11 @@ public class SysUserController extends BaseController {
         if (recommender == null) {
             return HttpResult.error("推荐人信息不存在");
         }
-
+        //只有团队长和代理人才能邀请 by gws
+        SysUserRole recommenderRole =sysUserRoleService.selectByUserId(recommenderid);
+        if(!"20".equals(recommenderRole.getRoleId())&&!"21".equals(recommenderRole.getRoleId())){
+            return HttpResult.error("只有团队长和代理人才能邀请");
+        }
         SysUser sysUser = sysUserService.findByPhone(dto.getMobile());
         if (sysUser != null) {
             return HttpResult.error("手机号已存在");
@@ -593,7 +597,36 @@ public class SysUserController extends BaseController {
 
 
                 if (StringUtils.isNullOrEmpty(a.getDeptId())) throw new SystemException("机构ID不能为空");
-
+                //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();
+                    char ch1 = 'D';
+                    char ch2 = 'M';
+                    if(deptids.length>6){
+                        teamflag=deptids[deptids.length-3]==ch1&&deptids[deptids.length-6]==ch2;
+                    }
+                    if(!teamflag){
+                        throw new SystemException("团队长和代理人只能归属团队中") ;
+                    }
+                }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(!deptflag){
+                        throw new SystemException("后线人员只能归属业务部门中") ;
+                    }
+                }else{
+                    throw new SystemException("角色id有误") ;
+                }
                 sysUserService.saveUser(a);
 
             });
@@ -630,6 +663,49 @@ public class SysUserController extends BaseController {
     @Transactional
     @PostMapping(value = "/saveUserInfo")
     public HttpResult saveUserInfo(@RequestBody SysUser2Vo sysUserVo){
+
+        //by gws 21	团队长 20	代理人 必须归属团队
+        // 22	后线人员 必须归属部门
+        SysUser sysUser=sysUserVo.getSysUser();
+        if (StringUtils.isNullOrEmpty(sysUser)) {
+            return HttpResult.error("用户信息不能为空");
+        }
+        if (StringUtils.isNullOrEmpty(sysUser.getDeptId())) {
+            return HttpResult.error("机构ID不能为空");
+        }
+        if (StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
+            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();
+                char ch1 = 'D';
+                char ch2 = 'M';
+                if(deptids.length>6){
+                    teamflag=deptids[deptids.length-3]==ch1&&deptids[deptids.length-6]==ch2;
+                }
+                if(!teamflag){
+                    throw new SystemException("团队长和代理人只能归属团队中") ;
+                }
+            }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(!deptflag){
+                    throw new SystemException("后线人员只能归属业务部门中") ;
+                }
+            }else{
+                throw new SystemException("角色id有误") ;
+            }
+
+        }
         return HttpResult.ok(sysUserService.saveUserInfo(sysUserVo)) ;
     }