|
|
@@ -10,6 +10,7 @@ import com.ydtech.core.page.HttpResult;
|
|
|
import com.ydtech.core.page.PageRequest;
|
|
|
import com.ydtech.core.page.PageResult;
|
|
|
import com.ydtech.exception.SystemException;
|
|
|
+import com.ydtech.modules.admin.constants.RoleConstants;
|
|
|
import com.ydtech.modules.admin.model.*;
|
|
|
import com.ydtech.modules.admin.model.dto.AgentUserDto;
|
|
|
import com.ydtech.modules.admin.model.dto.SysUserDto;
|
|
|
@@ -42,6 +43,7 @@ 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.concurrent.TimeUnit;
|
|
|
@@ -365,6 +367,23 @@ public class SysUserController extends BaseController {
|
|
|
@ApiOperation(value = "(重构)用户查询分页")
|
|
|
@PostMapping(value = "/findPage")
|
|
|
public HttpResult<PageVo<SysUserBaseVO>> findPage(@RequestBody PageDto<SysUserDto> pageDto) {
|
|
|
+ //获取用户角色
|
|
|
+ SysUser user = getUser();
|
|
|
+ List<String> roleIds = new ArrayList<String>();
|
|
|
+ //机构管理员
|
|
|
+ roleIds.add(RoleConstants.R42.getCode());
|
|
|
+ //后线人员
|
|
|
+ roleIds.add(RoleConstants.R22.getCode());
|
|
|
+ if(RoleConstants.R01.getCode().equals(user.getRoleId()) ||
|
|
|
+ RoleConstants.R01.getCode().equals(user.getRoleId())){
|
|
|
+ //部长
|
|
|
+ roleIds.add(RoleConstants.R17.getCode());
|
|
|
+ }
|
|
|
+ pageDto.getDto().setRoleId(String.join(",",roleIds));
|
|
|
+ //设置登录用户的部门
|
|
|
+ if("".equals(pageDto.getDto().getDeptId())) {
|
|
|
+ pageDto.getDto().setDeptId(user.getDeptId());
|
|
|
+ }
|
|
|
return HttpResult.ok(sysUserService.gainUserPage(pageDto));
|
|
|
|
|
|
}
|
|
|
@@ -698,7 +717,6 @@ public class SysUserController extends BaseController {
|
|
|
@ApiOperation(value = "保存用户基本详情信息")
|
|
|
@PostMapping(value = "/saveUserInfo")
|
|
|
public HttpResult saveUserInfo(@RequestBody SysUser2Vo sysUserVo) {
|
|
|
-
|
|
|
//by gws 21 团队长 20 代理人 必须归属团队
|
|
|
// 22 后线人员 必须归属部门
|
|
|
SysUser sysUser = sysUserVo.getSysUser();
|
|
|
@@ -711,32 +729,30 @@ public class SysUserController extends BaseController {
|
|
|
if (StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
|
|
|
throw new SystemException("角色id不能为空");
|
|
|
}
|
|
|
+ //获取机构层级
|
|
|
+ int deptLevel = sysUserService.getDeptLevel(sysUserVo);
|
|
|
if (!StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
|
|
|
- if ("21".equals(sysUser.getRoleId()) || "20".equals(sysUser.getRoleId())|| "19".equals(sysUser.getRoleId())) {//19 出单员 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) {
|
|
|
+ if (RoleConstants.R21.getCode().equals(sysUser.getRoleId())
|
|
|
+ || RoleConstants.R20.getCode().equals(sysUser.getRoleId())
|
|
|
+ || RoleConstants.R19.getCode().equals(sysUser.getRoleId())) {//19 出单员 21 团队长 20 代理人
|
|
|
+
|
|
|
+ if (deptLevel != 6) {
|
|
|
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 > 3) {
|
|
|
- deptflag = deptids[deptids.length - 3] == ch1;
|
|
|
- }
|
|
|
- if (!deptflag) {
|
|
|
+ } else if (RoleConstants.R22.getCode().equals(sysUser.getRoleId())) {//22 后线人员
|
|
|
+
|
|
|
+ if (deptLevel != 5) {
|
|
|
throw new SystemException("后线人员只能归属业务部门中");
|
|
|
}
|
|
|
- } else {
|
|
|
+ } else if (RoleConstants.R42.getCode().equals(sysUser.getRoleId())){ // 42 机构管理员
|
|
|
+ if(deptLevel != 5){
|
|
|
+ throw new SystemException("机构管理员只能归属机构中");
|
|
|
+ }
|
|
|
+ } else if(RoleConstants.R17.getCode().equals(sysUser.getRoleId())){
|
|
|
+ if(deptLevel != 4){
|
|
|
+ throw new SystemException("部长只能归属于4级");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
throw new SystemException("角色id有误");
|
|
|
}
|
|
|
|
|
|
@@ -745,6 +761,8 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation(value = "修改用户详情信息")
|
|
|
@PostMapping(value = "/updateUserInfo/{userId}")
|
|
|
@ApiImplicitParams({
|