feat(新增): 添加表单验证和Redis命名规范

This commit is contained in:
bunny 2024-09-27 08:29:56 +08:00
parent 59fe2875d7
commit 3a8c0af6e3
7 changed files with 37 additions and 34 deletions

View File

@ -53,6 +53,11 @@
<artifactId>swagger-annotations</artifactId>
<version>1.6.14</version>
</dependency>
<!-- 表单验证 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>

View File

@ -12,13 +12,16 @@ import lombok.NoArgsConstructor
@Schema(name = "EmailTemplateDto", title = "邮箱模板请求内容", description = "邮箱模板请求内容")
class EmailTemplateDto {
@Schema(name = "templateName", title = "模板名称")
var templateName: @NotBlank(message = "模板名称不能为空") String? = null
@NotBlank(message = "模板名称不能为空")
var templateName: String? = null
@Schema(name = "subject", title = "主题")
var subject: @NotBlank(message = "主题不能为空") String? = null
@NotBlank(message = "主题不能为空")
var subject: String? = null
@Schema(name = "body", title = "邮件内容")
var body: @NotBlank(message = "邮件内容不能为空") String? = null
@NotBlank(message = "邮件内容不能为空")
var body: String? = null
@Schema(name = "type", title = "邮件类型")
var type: String? = null

View File

@ -18,19 +18,23 @@ import lombok.NoArgsConstructor
@Schema(name = "EmailUsersDto", title = "邮箱用户发送基础内容", description = "邮箱用户发送基础内容")
class EmailUsersDto {
@Schema(name = "id", title = "主键")
var id: @NotBlank(message = "id不能为空") Long? = null
@NotBlank(message = "id不能为空")
var id: Long? = null
@Schema(name = "email", title = "邮箱")
var email: @NotBlank(message = "邮箱不能为空") String? = null
@NotBlank(message = "邮箱不能为空")
var email: String? = null
@Schema(name = "password", title = "密码")
var password: @NotBlank(message = "密码不能为空") String? = null
@NotBlank(message = "密码不能为空")
var password: String? = null
@Schema(name = "host", title = "SMTP服务器")
var host: String? = null
@Schema(name = "port", title = "端口号")
var port: @NotNull(message = "端口号不能为空") Int? = null
@NotNull(message = "端口号不能为空")
var port: Int? = null
@Schema(name = "smtpAgreement", title = "邮箱协议")
var smtpAgreement: Int? = null

View File

@ -14,11 +14,14 @@ import lombok.NoArgsConstructor
@Schema(name = "LoginDto", title = "登录表单内容", description = "登录表单内容")
class LoginDto {
@Schema(name = "username", title = "用户名")
var username: @NotBlank(message = "用户名不能为空") String? = null
@NotBlank(message = "用户名不能为空")
var username: String? = null
@Schema(name = "password", title = "密码")
var password: @NotBlank(message = "密码不能为空") String? = null
@NotBlank(message = "密码不能为空")
var password: String? = null
@Schema(name = "emailCode", title = "邮箱验证码")
var emailCode: @NotBlank(message = "邮箱验证码不能为空") String? = null
@NotBlank(message = "邮箱验证码不能为空")
var emailCode: String? = null
}

View File

@ -9,13 +9,12 @@ import lombok.Data
class RedisUserConstant {
companion object {
// 管理员用户
private const val ADMIN_LOGIN_INFO_PREFIX: String = "ADMIN::LOGIN_INFO::"
private const val ADMIN_EMAIL_CODE_PREFIX: String = "ADMIN::EMAIL_CODE::"
private const val ADMIN_LOGIN_INFO_PREFIX: String = "admin::login_info::"
private const val ADMIN_EMAIL_CODE_PREFIX: String = "admin::email_code::"
// 普通用户
private const val USER_LOGIN_INFO_PREFIX: String = "USER::LOGIN_INFO::"
private const val USER_EMAIL_CODE_PREFIX: String = "USER::EMAIL_CODE::"
private const val USER_DO_LIKE_PREFIX: String = "USER::doLike::"
private const val USER_LOGIN_INFO_PREFIX: String = "user::login_info::"
private const val USER_EMAIL_CODE_PREFIX: String = "user::email_code::"
/**
* * 管理员用户登录信息
@ -60,16 +59,5 @@ class RedisUserConstant {
fun getUserEmailCodePrefix(user: String): String {
return USER_EMAIL_CODE_PREFIX + user
}
/**
* * 用户点赞操作
*
* @param user 用户名
* @return 用户点赞key
*/
@JvmStatic
fun getUserDoLikePrefix(user: String): String {
return USER_DO_LIKE_PREFIX + user
}
}
}

View File

@ -0,0 +1,8 @@
package cn.bunny.dao.pojo.enums
enum class EmailTemplateTypes(val type: String, val summary: String) {
VERIFICATION_CODE("verification_code", "邮箱验证码发送"),
NOTIFICATION("notification", "通知型邮件"),
WARNING("warning", "警告型邮件"),
;
}

View File

@ -1,8 +0,0 @@
package cn.bunny.dao.pojo.enums
/**
* 数据库操作类型
*/
enum class OperationType {
UPDATE, INSERT
}