|
@@ -3,6 +3,7 @@ package com.ydtech.modules.admin.controller;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -820,15 +821,15 @@ public class SysUserController extends BaseController {
|
|
|
//by gws 21 团队长 20 代理人 必须归属团队
|
|
//by gws 21 团队长 20 代理人 必须归属团队
|
|
|
// 22 后线人员 必须归属部门
|
|
// 22 后线人员 必须归属部门
|
|
|
SysUser sysUser = sysUserVo.getSysUser();
|
|
SysUser sysUser = sysUserVo.getSysUser();
|
|
|
- SysUserInfo sysUserInfo = new SysUserInfo();
|
|
|
|
|
- if (sysUserVo.getIsPartner().equals("1")) {
|
|
|
|
|
|
|
+ if (sysUserVo.getIsPartner() != null && sysUserVo.getIsPartner().equals("1")) {
|
|
|
|
|
+ SysUserInfo sysUserInfo = new SysUserInfo();
|
|
|
SysUser partnerId = sysUserService.getById(sysUserVo.getSysUser().getReferrerId());
|
|
SysUser partnerId = sysUserService.getById(sysUserVo.getSysUser().getReferrerId());
|
|
|
sysUser.setDeptId(partnerId.getDeptId());
|
|
sysUser.setDeptId(partnerId.getDeptId());
|
|
|
sysUser.setStatus(2); //直接默认为入司待审核
|
|
sysUser.setStatus(2); //直接默认为入司待审核
|
|
|
LocalDate birthday = LocalDate.parse(sysUser.getIdentity().substring(6, 10) + "-" + sysUser.getIdentity().substring(10, 12) + "-" + sysUser.getIdentity().substring(12, 14));
|
|
LocalDate birthday = LocalDate.parse(sysUser.getIdentity().substring(6, 10) + "-" + sysUser.getIdentity().substring(10, 12) + "-" + sysUser.getIdentity().substring(12, 14));
|
|
|
sysUserInfo.setBirthday(birthday);
|
|
sysUserInfo.setBirthday(birthday);
|
|
|
|
|
+ sysUserVo.setSysUserInfo(sysUserInfo);
|
|
|
}
|
|
}
|
|
|
- sysUserVo.setSysUserInfo(sysUserInfo);
|
|
|
|
|
if (StringUtils.isNullOrEmpty(sysUser)) {
|
|
if (StringUtils.isNullOrEmpty(sysUser)) {
|
|
|
return HttpResult.error("用户信息不能为空");
|
|
return HttpResult.error("用户信息不能为空");
|
|
|
}
|
|
}
|
|
@@ -870,6 +871,66 @@ public class SysUserController extends BaseController {
|
|
|
return sysUserService.saveUserInfo(sysUserVo);
|
|
return sysUserService.saveUserInfo(sysUserVo);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "保存用户基本详情信息")
|
|
|
|
|
+ @PostMapping(value = "/saveTeamLeader")
|
|
|
|
|
+ public HttpResult saveTeamLeader(@RequestBody SysUser2Vo sysUserVo) {
|
|
|
|
|
+ SysUser sysUser = sysUserVo.getSysUser();
|
|
|
|
|
+ SysUserInfo sysUserInfo = new SysUserInfo();
|
|
|
|
|
+ LocalDate birthday = LocalDate.parse(sysUser.getIdentity().substring(6, 10) + "-" + sysUser.getIdentity().substring(10, 12) + "-" + sysUser.getIdentity().substring(12, 14));
|
|
|
|
|
+ sysUserInfo.setBirthday(birthday);
|
|
|
|
|
+ sysUserVo.setSysUserInfo(sysUserInfo);
|
|
|
|
|
+ // 先创建工作室下的团队
|
|
|
|
|
+ SysDept sysDept = sysDeptService.getOne(new LambdaQueryWrapper<SysDept>().eq(SysDept::getLeaderId, sysUser.getReferrerId()));
|
|
|
|
|
+ SysDeptVo sysDeptVo = new SysDeptVo();
|
|
|
|
|
+ sysDeptVo.setName(sysUser.getName() + "团队"); // 以人名设置工作室名称
|
|
|
|
|
+ sysDeptVo.setDeptType("D"); // 默认为子公司
|
|
|
|
|
+ sysDeptVo.setParentId(sysDept.getId());
|
|
|
|
|
+ sysDeptVo.setManagementSource(sysDept.getManagementSource()); //机构来源
|
|
|
|
|
+ sysDeptVo.setOrderNum(0);
|
|
|
|
|
+ sysDeptService.addDept(sysDeptVo);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNullOrEmpty(sysUser)) {
|
|
|
|
|
+ return HttpResult.error("用户信息不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNullOrEmpty(sysDeptVo.getId())) {
|
|
|
|
|
+ return HttpResult.error("机构ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
|
|
|
|
|
+ throw new SystemException("角色id不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ //获取机构层级
|
|
|
|
|
+ int deptLevel = sysUserService.getDeptLevel1(sysDeptVo.getId());
|
|
|
|
|
+ if (!StringUtils.isNullOrEmpty(sysUser.getRoleId())) {
|
|
|
|
|
+ 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("团队长、代理人、出单员只能归属团队中");
|
|
|
|
|
+ }
|
|
|
|
|
+ //如果为团队长,判断是否已经存在团队长,存在不允许添加 add by hxl 2024-05-07 ============begin
|
|
|
|
|
+ if (RoleConstants.R21.getCode().equals(sysUser.getRoleId())) {
|
|
|
|
|
+ int count = sysUserService.getCountByDeptAndRoleId(sysUser);
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new SystemException("该机构已存在团队长,不允许再添加!!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // =========================add by hxl end ====================
|
|
|
|
|
+ } else if (RoleConstants.R18.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级");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return sysUserService.saveUserInfo1(sysUserVo, sysDeptVo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@ApiOperation(value = "修改用户详情信息")
|
|
@ApiOperation(value = "修改用户详情信息")
|
|
|
@PostMapping(value = "/updateUserInfo/{userId}")
|
|
@PostMapping(value = "/updateUserInfo/{userId}")
|