1. 补全后端的其余模块
2. 新增用户管理多部门的逻辑
This commit is contained in:
@@ -22,4 +22,10 @@ public class DeptRespDTO {
|
||||
@Schema(description = "部门状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status; // 参见 CommonStatusEnum 枚举
|
||||
|
||||
@Schema(description = "是否公司", example = "false")
|
||||
private Boolean isCompany;
|
||||
|
||||
@Schema(description = "是否集团", example = "false")
|
||||
private Boolean isGroup;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fhs.core.trans.vo.VO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "RPC 服务 - Admin 用户 Response DTO")
|
||||
@@ -19,8 +20,8 @@ public class AdminUserRespDTO implements VO {
|
||||
@Schema(description = "帐号状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status; // 参见 CommonStatusEnum 枚举
|
||||
|
||||
@Schema(description = "部门编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long deptId;
|
||||
@Schema(description = "部门编号列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private List<Long> deptIds;
|
||||
|
||||
@Schema(description = "岗位编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1, 3]")
|
||||
private Set<Long> postIds;
|
||||
|
||||
@@ -172,6 +172,6 @@ public interface ErrorCodeConstants {
|
||||
// ========== 站内信发送 1-002-028-000 ==========
|
||||
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
|
||||
|
||||
// ========== 用户-租户关系 ==========
|
||||
ErrorCode USER_TENANT_NOT_EXISTS = new ErrorCode(1_002_028_000, "用户-租户关系不存在");
|
||||
// ========== 用户与部门关系 1-002-029-000 ==========
|
||||
ErrorCode USER_DEPT_NOT_EXISTS = new ErrorCode(1_002_029_000, "用户与部门关系不存在");
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 角色标识枚举
|
||||
*/
|
||||
@@ -13,7 +15,7 @@ public enum RoleCodeEnum {
|
||||
|
||||
SUPER_ADMIN("super_admin", "超级管理员"),
|
||||
TENANT_ADMIN("tenant_admin", "租户管理员"),
|
||||
CRM_ADMIN("crm_admin", "CRM 管理员"); // CRM 系统专用
|
||||
CRM_ADMIN("crm_admin", "CRM 管理员");
|
||||
;
|
||||
|
||||
/**
|
||||
@@ -29,4 +31,9 @@ public enum RoleCodeEnum {
|
||||
return ObjectUtils.equalsAny(code, SUPER_ADMIN.getCode());
|
||||
}
|
||||
|
||||
// 是否存在管理员角色编码
|
||||
public static boolean isAdmin(String code) {
|
||||
return ObjectUtils.equalsAny(code, Arrays.stream(RoleCodeEnum.values()).map(RoleCodeEnum::getCode).toArray(String[]::new));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,23 +45,25 @@ public class AdminUserApiImpl implements AdminUserApi {
|
||||
return success(Collections.emptyList());
|
||||
}
|
||||
ArrayList<Long> deptIds = new ArrayList<>();
|
||||
DeptDO dept = deptService.getDept(user.getDeptId());
|
||||
if (dept == null) {
|
||||
return success(Collections.emptyList());
|
||||
}
|
||||
if (ObjUtil.notEqual(dept.getLeaderUserId(), id)) { // 校验为负责人
|
||||
return success(Collections.emptyList());
|
||||
}
|
||||
deptIds.add(dept.getId());
|
||||
// 1.2 获取所有子部门
|
||||
List<DeptDO> childDeptList = deptService.getChildDeptList(dept.getId());
|
||||
if (CollUtil.isNotEmpty(childDeptList)) {
|
||||
deptIds.addAll(convertSet(childDeptList, DeptDO::getId));
|
||||
}
|
||||
|
||||
List<DeptDO> deptListByLeaderUserId = deptService.getDeptListByLeaderUserId(id);
|
||||
deptListByLeaderUserId.forEach(dept -> {
|
||||
if (dept == null) {
|
||||
return;
|
||||
}
|
||||
if (ObjUtil.notEqual(dept.getLeaderUserId(), id)) { // 校验为负责人
|
||||
return;
|
||||
}
|
||||
deptIds.add(dept.getId());
|
||||
// 1.2 获取所有子部门
|
||||
List<DeptDO> childDeptList = deptService.getChildDeptList(dept.getId());
|
||||
if (CollUtil.isNotEmpty(childDeptList)) {
|
||||
deptIds.addAll(convertSet(childDeptList, DeptDO::getId));
|
||||
}
|
||||
});
|
||||
// 2. 获取部门对应的用户信息
|
||||
List<AdminUserDO> users = userService.getUserListByDeptIds(deptIds);
|
||||
users.removeIf(item -> ObjUtil.equal(item.getId(), id)); // 排除自己
|
||||
// 排除自己
|
||||
users.removeIf(item -> ObjUtil.equal(item.getId(), id));
|
||||
return success(BeanUtils.toBean(users, AdminUserRespDTO.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.system.controller.admin.dept;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.DeptVisitIgnore;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
|
||||
@@ -72,13 +71,19 @@ public class DeptController {
|
||||
|
||||
@GetMapping(value = {"/list-all-simple", "/simple-list"})
|
||||
@Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
|
||||
@DeptVisitIgnore
|
||||
public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
|
||||
List<DeptDO> list = deptService.getDeptList(
|
||||
new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = {"/list-company-simple", "/simple-company-list"})
|
||||
@Operation(summary = "获取公司精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
|
||||
public CommonResult<List<DeptSimpleRespVO>> getSimpleCompanyList() {
|
||||
List<DeptDO> list = deptService.getUserCompanyList();
|
||||
return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得部门信息")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
|
||||
@@ -13,4 +13,9 @@ public class DeptListReqVO {
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否公司", example = "false")
|
||||
private Boolean isCompany;
|
||||
|
||||
@Schema(description = "是否集团", example = "false")
|
||||
private Boolean isGroup;
|
||||
}
|
||||
|
||||
@@ -42,4 +42,10 @@ public class DeptRespVO {
|
||||
@Schema(description = "租户编号", example = "1024")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "是否公司", example = "false")
|
||||
private Boolean isCompany;
|
||||
|
||||
@Schema(description = "是否集团", example = "false")
|
||||
private Boolean isGroup;
|
||||
|
||||
}
|
||||
|
||||
@@ -51,4 +51,10 @@ public class DeptSaveReqVO {
|
||||
@Schema(description = "租户编号", example = "1024")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(description = "是否公司", example = "false")
|
||||
private Boolean isCompany;
|
||||
|
||||
@Schema(description = "是否集团", example = "false")
|
||||
private Boolean isGroup;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,4 +23,10 @@ public class DeptSimpleRespVO {
|
||||
@Schema(description = "父部门 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "是否公司", example = "false")
|
||||
private Boolean isCompany;
|
||||
|
||||
@Schema(description = "是否集团", example = "false")
|
||||
private Boolean isGroup;
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user