From 2d2a6641fb516a141e8698f21eef3202e0d44749 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Tue, 26 Mar 2024 11:18:33 +0800 Subject: [PATCH] Optimize: parameters - optimize verification --- .../top/fatweb/oxygen/api/controller/tool/BaseController.kt | 1 - .../top/fatweb/oxygen/api/controller/tool/EditController.kt | 1 - .../top/fatweb/oxygen/api/param/permission/RegisterParam.kt | 2 +- .../top/fatweb/oxygen/api/param/permission/RetrieveParam.kt | 2 +- .../top/fatweb/oxygen/api/param/permission/VerifyParam.kt | 4 ++-- .../api/param/permission/user/UserChangePasswordParam.kt | 2 +- .../oxygen/api/param/permission/user/UserInfoUpdateParam.kt | 2 +- .../top/fatweb/oxygen/api/param/system/MailSendParam.kt | 2 +- src/main/resources/application-config-template.yml | 3 --- 9 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt index 5f607bf..8741981 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/BaseController.kt @@ -8,7 +8,6 @@ import top.fatweb.oxygen.api.annotation.BaseController import top.fatweb.oxygen.api.annotation.Trim import top.fatweb.oxygen.api.entity.common.ResponseCode import top.fatweb.oxygen.api.entity.common.ResponseResult -import top.fatweb.oxygen.api.param.PageSortParam import top.fatweb.oxygen.api.param.tool.ToolBaseAddParam import top.fatweb.oxygen.api.param.tool.ToolBaseGetParam import top.fatweb.oxygen.api.param.tool.ToolBaseUpdateParam diff --git a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt index 41aaed9..c805d84 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/controller/tool/EditController.kt @@ -2,7 +2,6 @@ package top.fatweb.oxygen.api.controller.tool import io.swagger.v3.oas.annotations.Operation import jakarta.validation.Valid -import jakarta.validation.constraints.NotNull import org.springframework.web.bind.annotation.* import top.fatweb.oxygen.api.annotation.BaseController import top.fatweb.oxygen.api.annotation.Trim diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RegisterParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RegisterParam.kt index 3280d1f..59bf97d 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RegisterParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RegisterParam.kt @@ -49,6 +49,6 @@ data class RegisterParam( */ @Schema(description = "密码", required = true) @field:NotBlank(message = "Password can not be blank") - @field:Size(min = 10, max = 30, message = "Password must be 10-20 characters") + @field:Size(min = 10, max = 30, message = "Password must be 10-30 characters") val password: String? ) : CaptchaCodeParam() \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RetrieveParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RetrieveParam.kt index 1b8f685..5163e5f 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RetrieveParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/RetrieveParam.kt @@ -32,6 +32,6 @@ data class RetrieveParam( */ @Schema(description = "新密码") @field:NotBlank(message = "New password can not be blank") - @field:Size(min = 10, max = 30) + @field:Size(min = 10, max = 30, message = "New password must be 10-30 characters") val password: String? ) : CaptchaCodeParam() diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/VerifyParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/VerifyParam.kt index a9be0c0..ebe1cd3 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/VerifyParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/VerifyParam.kt @@ -2,7 +2,7 @@ package top.fatweb.oxygen.api.param.permission import io.swagger.v3.oas.annotations.media.Schema import jakarta.validation.constraints.NotBlank -import jakarta.validation.constraints.Pattern +import jakarta.validation.constraints.Size import top.fatweb.oxygen.api.annotation.Trim /** @@ -32,7 +32,7 @@ data class VerifyParam( */ @Trim @Schema(description = "昵称", example = "QwQ") - @field:Pattern(regexp = "^.{3,20}$", message = "Nickname must be 3-20 characters") + @field:Size(min = 3, max = 20, message = "Nickname must be 3-20 characters") var nickname: String?, /** diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserChangePasswordParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserChangePasswordParam.kt index 7e704e6..094c3b5 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserChangePasswordParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserChangePasswordParam.kt @@ -30,6 +30,6 @@ data class UserChangePasswordParam( */ @Schema(description = "原密码", required = true) @field:NotBlank(message = "New password can not be blank") - @field:Size(min = 10, max = 30, message = "New password must be 10-20 characters") + @field:Size(min = 10, max = 30, message = "New password must be 10-30 characters") val newPassword: String? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserInfoUpdateParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserInfoUpdateParam.kt index 4aae0a9..7928cf6 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserInfoUpdateParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/permission/user/UserInfoUpdateParam.kt @@ -32,6 +32,6 @@ data class UserInfoUpdateParam( @Trim @Schema(description = "昵称", example = "QwQ") @field:NotBlank(message = "Nickname can not be blank") - @field:Size(min = 3, max = 30, message = "Nickname must be 3-20 characters") + @field:Size(min = 3, max = 20, message = "Nickname must be 3-20 characters") var nickname: String? ) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSendParam.kt b/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSendParam.kt index 842c49a..bdbdde1 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSendParam.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/param/system/MailSendParam.kt @@ -21,6 +21,6 @@ data class MailSendParam( */ @Trim @Schema(description = "接收者", required = true, example = "user@email.com") - @field:NotBlank + @field:NotBlank(message = "Receiver cannot be blank") var to: String? ) diff --git a/src/main/resources/application-config-template.yml b/src/main/resources/application-config-template.yml index d42e842..6747dbc 100644 --- a/src/main/resources/application-config-template.yml +++ b/src/main/resources/application-config-template.yml @@ -62,8 +62,5 @@ logging: # max-file-size: 10MB # Maximum log file size # max-history: 7 # Maximum number of archive log files to keep -mybatis-plus: - type-aliases-package: top.fatweb.oxygen.api.entity - knife4j: production: true # Production environment mode will block doc \ No newline at end of file -- 2.49.1