Browse Source
- new DeptDTO (extends BaseDTO, children tree, fromEntity/toEntity) - new AssignDeptDTO (plain POJO, no key semantics) - rename UserStatsVO -> UserStatsDTO - menuTree returns List<ResourceNodeDTO>; PermissionResolver.visibleMenuTree maps entity->DTO before tree build - deptTree returns List<DeptDTO>; saveDept takes DeptDTO; assignUserDepts takes AssignDeptDTO - userPage drops @RequestBody -> form binding (aligns with documented form-urlencoded convention) - sync role-management doc RoleDetailVO -> RoleDTO - DataScopeIntegrationTest updated for ResourceNodeDTOmaster
12 changed files with 158 additions and 79 deletions
@ -0,0 +1,28 @@ |
|||
package com.crm.auth.domain.dto; |
|||
|
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serial; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 分配用户部门入参(ADR-0017;纯 POJO,无主键语义故不继承 BaseDTO) |
|||
* <p>原子设置用户主部门与全部兼职部门(全量替换,校验与事务在 Service 层)。 |
|||
* deptIds 为逗号分隔的兼职部门 ID 串,由 Controller 拆分。</p> |
|||
*/ |
|||
@Data |
|||
public class AssignDeptDTO implements Serializable { |
|||
|
|||
@Serial |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Schema(description = "用户 ID") |
|||
private Long userId; |
|||
|
|||
@Schema(description = "主部门 ID,可空") |
|||
private Long primaryDeptId; |
|||
|
|||
@Schema(description = "兼职部门 ID 列表,逗号分隔,可空") |
|||
private String deptIds; |
|||
} |
|||
@ -0,0 +1,59 @@ |
|||
package com.crm.auth.domain.dto; |
|||
|
|||
import com.crm.auth.domain.entity.SysDept; |
|||
import com.crm.base.domain.dto.BaseDTO; |
|||
import io.swagger.v3.oas.annotations.media.Schema; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 部门传输对象(ADR-0017 Route A:save 写入参 + deptTree 出参双向) |
|||
* <p>继承 {@link BaseDTO} 白拿 id/createTime/updateTime;createTime/updateTime 由全局 |
|||
* @InitBinder 在入参侧 strip,出参侧展示原值。ancestors 为冗余字段不出参。</p> |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = true) |
|||
public class DeptDTO extends BaseDTO { |
|||
|
|||
@Schema(description = "上级部门 ID,根节点为 0") |
|||
private Long parentId; |
|||
|
|||
@Schema(description = "部门名称") |
|||
private String deptName; |
|||
|
|||
@Schema(description = "排序") |
|||
private Integer sort; |
|||
|
|||
@Schema(description = "部门负责人用户 ID") |
|||
private Long leaderUserId; |
|||
|
|||
@Schema(description = "子部门列表(仅 deptTree 返回时填充)") |
|||
private List<DeptDTO> children; |
|||
|
|||
/** SysDept → DeptDTO(不含 children,树结构由 TreeUtils 组装) */ |
|||
public static DeptDTO fromEntity(SysDept entity) { |
|||
if (entity == null) { |
|||
return null; |
|||
} |
|||
DeptDTO dto = new DeptDTO(); |
|||
dto.setId(entity.getId()); |
|||
dto.setParentId(entity.getParentId()); |
|||
dto.setDeptName(entity.getDeptName()); |
|||
dto.setSort(entity.getSort()); |
|||
dto.setLeaderUserId(entity.getLeaderUserId()); |
|||
return dto; |
|||
} |
|||
|
|||
/** DeptDTO → SysDept(写入参转换;ancestors/审计字段由服务端裁定,不映射) */ |
|||
public SysDept toEntity() { |
|||
SysDept entity = new SysDept(); |
|||
entity.setId(this.getId()); |
|||
entity.setParentId(this.parentId); |
|||
entity.setDeptName(this.deptName); |
|||
entity.setSort(this.sort); |
|||
entity.setLeaderUserId(this.leaderUserId); |
|||
return entity; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue