feat(user-management-relation): 完成带人关系后端接口(即直接管理)

This commit is contained in:
dk
2026-04-10 16:26:59 +08:00
parent 017beb1d5f
commit 21ca027f3b
13 changed files with 1343 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
package com.njcn.rdms.module.system.api.user;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import com.njcn.rdms.framework.common.pojo.CommonResult;
import com.njcn.rdms.framework.common.util.collection.CollectionUtils;
import com.njcn.rdms.module.system.api.user.dto.UserManagementRelationRespDTO;
import com.njcn.rdms.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@FeignClient(name = ApiConstants.NAME)
@Tag(name = "RPC 服务 - 用户带人关系")
public interface UserManagementRelationApi {
String PREFIX = ApiConstants.PREFIX + "/user-management-relation";
@GetMapping(PREFIX + "/list-by-manager")
@Operation(summary = "根据管理者用户ID获得带人关系列表")
@Parameter(name = "managerUserId", description = "管理者用户ID", example = "1", required = true)
CommonResult<List<UserManagementRelationRespDTO>> getRelationListByManagerUserId(@RequestParam("managerUserId") Long managerUserId);
@GetMapping(PREFIX + "/list-by-subordinate")
@Operation(summary = "根据被管理者用户ID获得带人关系列表")
@Parameter(name = "subordinateUserId", description = "被管理者用户ID", example = "2", required = true)
CommonResult<List<UserManagementRelationRespDTO>> getRelationListBySubordinateUserId(@RequestParam("subordinateUserId") Long subordinateUserId);
@GetMapping(PREFIX + "/list")
@Operation(summary = "获得带人关系列表")
@Parameter(name = "ids", description = "关系编号数组", example = "1,2", required = true)
CommonResult<List<UserManagementRelationRespDTO>> getRelationList(@RequestParam("ids") Collection<Long> ids);
default Map<Long, UserManagementRelationRespDTO> getRelationMap(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return MapUtil.empty();
}
List<UserManagementRelationRespDTO> list = getRelationList(ids).getData();
return CollectionUtils.convertMap(list, UserManagementRelationRespDTO::getId);
}
}

View File

@@ -0,0 +1,35 @@
package com.njcn.rdms.module.system.api.user.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 用户带人关系 Response DTO
*
* @author dklive
*/
@Schema(description = "RPC 服务 - 用户带人关系 Response DTO")
@Data
public class UserManagementRelationRespDTO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "管理者用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long managerUserId;
@Schema(description = "被管理用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Long subordinateUserId;
@Schema(description = "生效开始时间")
private LocalDateTime effectiveFrom;
@Schema(description = "生效结束时间")
private LocalDateTime effectiveUntil;
@Schema(description = "备注")
private String remark;
}

View File

@@ -54,6 +54,10 @@ public interface ErrorCodeConstants {
ErrorCode USER_REGISTER_DISABLED = new ErrorCode(1_002_003_011, "注册功能已关闭");
ErrorCode USER_IS_RESIGNED = new ErrorCode(1_002_003_012, "名字为【{}】的用户已离职");
// ========== 用户带人关系模块 1-002-003-100 ==========
ErrorCode USER_MANAGEMENT_RELATION_NOT_FOUND = new ErrorCode(1_002_003_100, "用户带人关系不存在");
ErrorCode USER_MANAGEMENT_RELATION_MANAGER_EXISTS = new ErrorCode(1_002_003_101, "该用户已有直属上级,不能重复添加");
// ========== 部门模块 1-002-004-000 ==========
ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门");
ErrorCode DEPT_PARENT_NOT_EXITS = new ErrorCode(1_002_004_001,"父级部门不存在");