refactor: 邮件和通知模板删除校验

This commit is contained in:
caiyuchao
2025-08-11 17:46:59 +08:00
parent 8b387fef0f
commit deded106a9
4 changed files with 16 additions and 40 deletions

View File

@@ -3,9 +3,6 @@ package org.agt.module.system.api.mail.dto;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@Schema(description = "管理后台 - 邮件模版创建/修改 Request DTO") @Schema(description = "管理后台 - 邮件模版创建/修改 Request DTO")
@Data @Data
public class MailTemplateSaveReqDTO { public class MailTemplateSaveReqDTO {
@@ -14,30 +11,24 @@ public class MailTemplateSaveReqDTO {
private Long id; private Long id;
@Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试名字") @Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试名字")
@NotNull(message = "名称不能为空")
private String name; private String name;
@Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "test")
@NotNull(message = "模版编号不能为空")
private String code; private String code;
@Schema(description = "发送的邮箱账号编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "发送的邮箱账号编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "发送的邮箱账号编号不能为空")
private Long accountId; private Long accountId;
@Schema(description = "发送人名称", example = "芋头") @Schema(description = "发送人名称", example = "芋头")
private String nickname; private String nickname;
@Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "注册成功") @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "注册成功")
@NotEmpty(message = "标题不能为空")
private String title; private String title;
@Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,注册成功啦") @Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,注册成功啦")
@NotEmpty(message = "内容不能为空")
private String content; private String content;
@Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态不能为空")
private Integer status; private Integer status;
@Schema(description = "备注", example = "奥特曼") @Schema(description = "备注", example = "奥特曼")

View File

@@ -1,12 +1,9 @@
package org.agt.module.system.api.notify.dto; package org.agt.module.system.api.notify.dto;
import org.agt.framework.common.enums.CommonStatusEnum;
import org.agt.framework.common.validation.InEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.agt.framework.common.enums.CommonStatusEnum;
import jakarta.validation.constraints.NotEmpty; import org.agt.framework.common.validation.InEnum;
import jakarta.validation.constraints.NotNull;
@Schema(description = "管理后台 - 站内信模版创建/修改 Request DTO") @Schema(description = "管理后台 - 站内信模版创建/修改 Request DTO")
@Data @Data
@@ -16,27 +13,21 @@ public class NotifyTemplateSaveReqDTO {
private Long id; private Long id;
@Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版") @Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版")
@NotEmpty(message = "模版名称不能为空")
private String name; private String name;
@Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SEND_TEST") @Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SEND_TEST")
@NotNull(message = "模版编码不能为空")
private String code; private String code;
@Schema(description = "模版类型,对应 system_notify_template_type 字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "模版类型,对应 system_notify_template_type 字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "模版类型不能为空")
private Integer type; private Integer type;
@Schema(description = "发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") @Schema(description = "发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆")
@NotEmpty(message = "发送人名称不能为空")
private String nickname; private String nickname;
@Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是模版内容") @Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是模版内容")
@NotEmpty(message = "模版内容不能为空")
private String content; private String content;
@Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}") @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}")
private Integer status; private Integer status;

View File

@@ -3,9 +3,6 @@ package org.agt.module.system.controller.admin.mail.vo.template;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@Schema(description = "管理后台 - 邮件模版创建/修改 Request VO") @Schema(description = "管理后台 - 邮件模版创建/修改 Request VO")
@Data @Data
public class MailTemplateSaveReqVO { public class MailTemplateSaveReqVO {
@@ -14,30 +11,30 @@ public class MailTemplateSaveReqVO {
private Long id; private Long id;
@Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试名字") @Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试名字")
@NotNull(message = "名称不能为空") // @NotNull(message = "名称不能为空")
private String name; private String name;
@Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") @Schema(description = "模版编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "test")
@NotNull(message = "模版编号不能为空") // @NotNull(message = "模版编号不能为空")
private String code; private String code;
@Schema(description = "发送的邮箱账号编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "发送的邮箱账号编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "发送的邮箱账号编号不能为空") // @NotNull(message = "发送的邮箱账号编号不能为空")
private Long accountId; private Long accountId;
@Schema(description = "发送人名称", example = "芋头") @Schema(description = "发送人名称", example = "芋头")
private String nickname; private String nickname;
@Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "注册成功") @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "注册成功")
@NotEmpty(message = "标题不能为空") // @NotEmpty(message = "标题不能为空")
private String title; private String title;
@Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,注册成功啦") @Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,注册成功啦")
@NotEmpty(message = "内容不能为空") // @NotEmpty(message = "内容不能为空")
private String content; private String content;
@Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态不能为空") // @NotNull(message = "状态不能为空")
private Integer status; private Integer status;
@Schema(description = "备注", example = "奥特曼") @Schema(description = "备注", example = "奥特曼")

View File

@@ -1,12 +1,9 @@
package org.agt.module.system.controller.admin.notify.vo.template; package org.agt.module.system.controller.admin.notify.vo.template;
import org.agt.framework.common.enums.CommonStatusEnum;
import org.agt.framework.common.validation.InEnum;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.agt.framework.common.enums.CommonStatusEnum;
import jakarta.validation.constraints.NotEmpty; import org.agt.framework.common.validation.InEnum;
import jakarta.validation.constraints.NotNull;
@Schema(description = "管理后台 - 站内信模版创建/修改 Request VO") @Schema(description = "管理后台 - 站内信模版创建/修改 Request VO")
@Data @Data
@@ -16,27 +13,27 @@ public class NotifyTemplateSaveReqVO {
private Long id; private Long id;
@Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版") @Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版")
@NotEmpty(message = "模版名称不能为空") // @NotEmpty(message = "模版名称不能为空")
private String name; private String name;
@Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SEND_TEST") @Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SEND_TEST")
@NotNull(message = "模版编码不能为空") // @NotNull(message = "模版编码不能为空")
private String code; private String code;
@Schema(description = "模版类型,对应 system_notify_template_type 字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "模版类型,对应 system_notify_template_type 字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "模版类型不能为空") // @NotNull(message = "模版类型不能为空")
private Integer type; private Integer type;
@Schema(description = "发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆") @Schema(description = "发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆")
@NotEmpty(message = "发送人名称不能为空") // @NotEmpty(message = "发送人名称不能为空")
private String nickname; private String nickname;
@Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是模版内容") @Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是模版内容")
@NotEmpty(message = "模版内容不能为空") // @NotEmpty(message = "模版内容不能为空")
private String content; private String content;
@Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "状态不能为空") // @NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}") @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}")
private Integer status; private Integer status;