feat: add system management Response DTOs
- Add UserResponse for user management endpoints - Add RoleResponse for role management endpoints - Add PermissionResponse for permission management endpoints - Add MenuResponse for flat menu list endpoints - Add MenuTreeResponse for hierarchical menu structure - Add MeResponse for current user information endpoint These DTOs align with the SystemController and MeController endpoints for complete system management functionality. Co-authored-by: Qwen-Coder <[email protected]>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public record CreateMenuRequest(
|
||||
Long parentId,
|
||||
@NotBlank @Size(max = 64) String code,
|
||||
@NotBlank @Size(max = 128) String name,
|
||||
@Size(max = 256) String path,
|
||||
@Size(max = 64) String icon,
|
||||
Integer sortOrder,
|
||||
@NotBlank String menuType
|
||||
) {}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public record CreatePermissionRequest(
|
||||
@NotBlank @Pattern(regexp = "^[a-z][a-z0-9_]*:[a-z][a-z0-9_]*:[a-z][a-z0-9_]*$",
|
||||
message = "权限编码必须为三段式")
|
||||
@Size(max = 128) String code,
|
||||
@NotBlank @Size(max = 256) String name,
|
||||
@NotBlank @Pattern(regexp = "^(API|PAGE|ACTION)$") String type,
|
||||
@Size(max = 512) String description
|
||||
) {}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public record CreateRoleRequest(
|
||||
@NotBlank @Size(max = 64)
|
||||
@Pattern(regexp = "^[A-Z][A-Z0-9_]*$", message = "角色编码必须大写字母开头")
|
||||
String code,
|
||||
@NotBlank @Size(max = 128) String name,
|
||||
@Size(max = 512) String description
|
||||
) {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
public record CreateUserRequest(
|
||||
@NotBlank @Size(max = 64) String username,
|
||||
@NotBlank @Size(max = 128) String displayName,
|
||||
@Email @Size(max = 128) String email
|
||||
) {}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 当前用户信息响应 DTO
|
||||
* 用于 /api/v1/me
|
||||
*/
|
||||
public record MeResponse(
|
||||
Long id,
|
||||
String tenantId,
|
||||
String username,
|
||||
String nickname,
|
||||
String avatar,
|
||||
List<String> roleCodes
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 菜单响应 DTO(平铺,非树形)
|
||||
*/
|
||||
public record MenuResponse(
|
||||
Long id,
|
||||
String tenantId,
|
||||
Long parentId,
|
||||
String menuCode,
|
||||
String menuName,
|
||||
String menuType,
|
||||
String path,
|
||||
String component,
|
||||
String icon,
|
||||
Integer sortOrder,
|
||||
Boolean visible,
|
||||
Integer status,
|
||||
LocalDateTime createTime,
|
||||
LocalDateTime updateTime
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单树响应 DTO(递归结构)
|
||||
* 用于 /api/v1/system/menus/tree 和 /api/v1/me/menus
|
||||
*/
|
||||
public record MenuTreeResponse(
|
||||
Long id,
|
||||
Long parentId,
|
||||
String menuCode,
|
||||
String menuName,
|
||||
String menuType,
|
||||
String path,
|
||||
String component,
|
||||
String icon,
|
||||
Integer sortOrder,
|
||||
Boolean visible,
|
||||
List<MenuTreeResponse> children
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 权限响应 DTO
|
||||
*/
|
||||
public record PermissionResponse(
|
||||
Long id,
|
||||
String tenantId,
|
||||
String permissionCode,
|
||||
String permissionName,
|
||||
String permissionType,
|
||||
String description,
|
||||
Integer status,
|
||||
LocalDateTime createTime,
|
||||
LocalDateTime updateTime
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 角色响应 DTO
|
||||
*/
|
||||
public record RoleResponse(
|
||||
Long id,
|
||||
String tenantId,
|
||||
String roleCode,
|
||||
String roleName,
|
||||
String description,
|
||||
Integer sortOrder,
|
||||
Integer status,
|
||||
LocalDateTime createTime,
|
||||
LocalDateTime updateTime
|
||||
) {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
/** 更新菜单 — 不允许修改 code。parentId 如需变更需显式传入(含防环校验)。 */
|
||||
public record UpdateMenuRequest(
|
||||
@Size(max = 128) String name,
|
||||
@Size(max = 256) String path,
|
||||
@Size(max = 64) String icon,
|
||||
Integer sortOrder,
|
||||
Long parentId,
|
||||
Boolean visible
|
||||
) {}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
/** 更新权限点 — 不允许修改 code 和 type。 */
|
||||
public record UpdatePermissionRequest(
|
||||
@Size(max = 256) String name,
|
||||
@Size(max = 512) String description
|
||||
) {}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
/** 更新角色 — 不允许修改 code。 */
|
||||
public record UpdateRoleRequest(
|
||||
@Size(max = 128) String name,
|
||||
@Size(max = 512) String description,
|
||||
Boolean enabled
|
||||
) {}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
/** 更新用户 — 所有字段可选,非 null 才更新。不允许修改 username。 */
|
||||
public record UpdateUserRequest(
|
||||
@Size(max = 128) String displayName,
|
||||
@Email @Size(max = 128) String email,
|
||||
Boolean enabled
|
||||
) {}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.ljwx.tmpl.api.dto.system;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 用户响应 DTO
|
||||
*/
|
||||
public record UserResponse(
|
||||
Long id,
|
||||
String tenantId,
|
||||
String username,
|
||||
String nickname,
|
||||
String email,
|
||||
String phone,
|
||||
String avatar,
|
||||
Integer status,
|
||||
LocalDateTime createTime,
|
||||
LocalDateTime updateTime
|
||||
) {
|
||||
}
|
||||
Reference in New Issue
Block a user