参数校验

This commit is contained in:
2025-04-30 00:02:24 +08:00
parent 2ce8f06cfb
commit dc090de5ab
8 changed files with 67 additions and 20 deletions

View File

@ -1,5 +1,7 @@
package com.greenorange.promotion.model.dto.user;
import com.greenorange.promotion.annotation.EnumValue;
import com.greenorange.promotion.model.enums.UserRoleEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
@ -13,7 +15,7 @@ import java.io.Serializable;
* 用户添加请求体
*/
@Data
@Schema(description = "用户添加请求体", requiredProperties = {"nickName", "userAvatar", "phoneNumber",
@Schema(description = "用户添加请求体", requiredProperties = {"nickName", "userAvatar", "phoneNumber",
"userAccount", "userPassword", "userRole"})
public class UserInfoAddRequest implements Serializable {
@ -63,9 +65,9 @@ public class UserInfoAddRequest implements Serializable {
/**
* 用户角色
*/
@NotBlank(message = "用户角色不能为空")
@Schema(description = "用户角色", example = "user")
private String userRole;
@EnumValue(enumClass = UserRoleEnum.class)
@Schema(description = "用户角色", example = "USER")
private UserRoleEnum userRole;
/**
* 上级用户id

View File

@ -19,7 +19,7 @@ public class UserInfoLoginRequest implements Serializable {
*/
@NotBlank(message = "账号不能为空")
@Size(min = 6, max = 10, message = "账号长度在 6 到 10 个字符")
@Schema(description = "账号", example = "qingcheng_account")
@Schema(description = "账号", example = "qingcheng")
private String userAccount;
/**
@ -27,7 +27,7 @@ public class UserInfoLoginRequest implements Serializable {
*/
@NotBlank(message = "密码不能为空")
@Size(min = 6, max = 10, message = "密码长度在 6 到 10 个字符")
@Schema(description = "密码", example = "qingcheng_password")
@Schema(description = "密码", example = "qingcheng")
private String userPassword;
}

View File

@ -13,7 +13,7 @@ import com.greenorange.promotion.common.PageRequest;
* 用户查询请求体,继承自分页请求 PageRequest
*/
@Data
@Schema(description = "用户查询请求体", requiredProperties = {"current", "pageSize"})
@Schema(description = "用户查询请求体", requiredProperties = {"current", "pageSize"})
public class UserInfoQueryRequest extends PageRequest implements Serializable {
/**

View File

@ -14,7 +14,7 @@ import java.io.Serializable;
* 用户更新请求体
*/
@Data
@Schema(description = "用户更新请求体", requiredProperties = {"id", "nickName", "userAvatar", "phoneNumber",
@Schema(description = "用户更新请求体", requiredProperties = {"id", "nickName", "userAvatar", "phoneNumber",
"userAccount", "userPassword", "userRole"})
public class UserInfoUpdateRequest implements Serializable {
@ -52,7 +52,7 @@ public class UserInfoUpdateRequest implements Serializable {
*/
@NotBlank(message = "账号不能为空")
@Size(min = 6, max = 10, message = "账号长度在 6 到 10 个字符")
@Schema(description = "账号", example = "qingcheng_account")
@Schema(description = "账号", example = "qingcheng")
private String userAccount;
/**
@ -60,7 +60,7 @@ public class UserInfoUpdateRequest implements Serializable {
*/
@NotBlank(message = "密码不能为空")
@Size(min = 6, max = 10, message = "密码长度在 6 到 10 个字符")
@Schema(description = "密码", example = "qingcheng_password")
@Schema(description = "密码", example = "qingcheng")
private String userPassword;
/**