Browse Source

# feat:用户相关实体的接口文档信息完善
- 使用Schema注解

yang yi 1 tuần trước cách đây
mục cha
commit
1446520a46

+ 4 - 0
src/main/java/space/anyi/serve/entity/PageVo.java

@@ -1,6 +1,7 @@
 package space.anyi.serve.entity;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.v3.oas.annotations.media.Schema;
 
 /**
  * @fileName: PageVo
@@ -10,8 +11,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  * @date:2026/3/31 22:35
  * @description:
  */
+@Schema(description = "分页数据对象")
 public final class PageVo<T> {
+    @Schema(description = "总数据条数")
     private final Long total;
+    @Schema(description = "当前页的数据")
     private final T data;
 
     public PageVo(Long total, T data) {

+ 6 - 0
src/main/java/space/anyi/serve/entity/Response.java

@@ -1,5 +1,7 @@
 package space.anyi.serve.entity;
 
+import io.swagger.v3.oas.annotations.media.Schema;
+
 /**
  * @fileName: Response
  * @projectName: serve
@@ -8,12 +10,16 @@ package space.anyi.serve.entity;
  * @date:2026/4/1 9:03
  * @description:
  */
+@Schema(description = "后端统一的响应实体")
 public final class Response<T> {
     public static final Integer SUCCESS_CODE = 200;
     public static final Integer ERROR_CODE = 200;
 
+    @Schema(description = "状态码;200:成功")
     private Integer code;
+    @Schema(description = "响应附加信息")
     private String message;
+    @Schema(description = "响应的具体数据")
     private T data;
 
     public Integer getCode() {

+ 15 - 0
src/main/java/space/anyi/serve/entity/user/UpdateUserAvatarDto.java

@@ -1,5 +1,9 @@
 package space.anyi.serve.entity.user;
 
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+
 /**
  * @fileName: UpdateUserAvatarDto
  * @projectName: serve
@@ -8,8 +12,19 @@ package space.anyi.serve.entity.user;
  * @date:2026/4/29 9:11
  * @description:
  */
+@Schema(
+        description = "更新用户头像的实体DTO",
+        requiredProperties = {
+                "id",
+                "avatar",
+        }
+)
 public class UpdateUserAvatarDto {
+    @NotBlank(message = "用户ID不能为空")
+    @Schema(description = "用户的ID")
     private String id;
+    @NotBlank(message = "头像不能链接地址不能为空")
+    @Schema(description = "头像地址的链接")
     private String avatar;
 
     public String getId() {

+ 6 - 0
src/main/java/space/anyi/serve/entity/user/UpdateUserPasswordDto.java

@@ -1,5 +1,7 @@
 package space.anyi.serve.entity.user;
 
+import io.swagger.v3.oas.annotations.media.Schema;
+
 /**
  * @fileName: UpdateUserPasswordDto
  * @projectName: serve
@@ -8,9 +10,13 @@ package space.anyi.serve.entity.user;
  * @date:2026/4/29 9:15
  * @description:
  */
+@Schema(description = "用户密码修改使用的DTO")
 public class UpdateUserPasswordDto {
+    @Schema(description = "用户ID")
     private String id;
+    @Schema(description = "用户的当前密码")
     private String password;
+    @Schema(description = "用户的新密码")
     private String oldPassword;
 
     public String getId() {

+ 8 - 3
src/main/java/space/anyi/serve/entity/user/UpdateUserStatusDto.java

@@ -1,6 +1,8 @@
 package space.anyi.serve.entity.user;
 
-import org.springframework.lang.NonNull;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.SchemaProperty;
+import jakarta.validation.constraints.NotBlank;
 
 /**
  * @fileName: UpdateUserStatusDto
@@ -10,10 +12,13 @@ import org.springframework.lang.NonNull;
  * @date:2026/4/29 9:05
  * @description:
  */
+@Schema(description = "用户状态更新使用的DTO")
 public class UpdateUserStatusDto {
-    @NonNull
+    @NotBlank
+    @Schema(description = "用户ID")
     private String id;
-    @NonNull
+    @NotBlank
+    @Schema(description = "更新后的状态;1:启用,0:禁用")
     private Integer enable;
 
     public String getId() {

+ 7 - 0
src/main/java/space/anyi/serve/entity/user/UserDto.java

@@ -1,5 +1,6 @@
 package space.anyi.serve.entity.user;
 
+import io.swagger.v3.oas.annotations.media.Schema;
 import org.springframework.lang.NonNull;
 
 /**
@@ -10,11 +11,17 @@ import org.springframework.lang.NonNull;
  * @date:2026/3/31 20:42
  * @description:
  */
+@Schema(description = "用户新增和修改使用的DTO")
 public class UserDto {
+    @Schema(description = "用户ID")
     private String id;
+    @Schema(description = "用户账号")
     private String account;
+    @Schema(description = "用户密码")
     private String password;
+    @Schema(description = "用户名称")
     private String username;
+    @Schema(description = "用户角色")
     private String role;
 
     public String getId() {

+ 9 - 0
src/main/java/space/anyi/serve/entity/user/UserVo.java

@@ -1,6 +1,8 @@
 package space.anyi.serve.entity.user;
 
 
+import io.swagger.v3.oas.annotations.media.Schema;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -13,12 +15,19 @@ import java.util.Objects;
  * @date:2026/4/1 8:54
  * @description:
  */
+@Schema(description = "用户响应展示对象")
 public class UserVo {
+    @Schema(description = "用户ID")
     private String id;
+    @Schema(description = "用户账号")
     private String account;
+    @Schema(description = "用户名称")
     private String username;
+    @Schema(description = "用户角色")
     private String role;
+    @Schema(description = "用户头像地址")
     private String avatar;
+    @Schema(description = "用户状态;0:禁用,1:启用")
     private Integer enable = 1;
 
     public String getId() {