mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 05:12:07 +08:00
字段管理、菜单管理、短信管理接口入参检查完善
This commit is contained in:
+2
-3
@@ -1,8 +1,7 @@
|
||||
package com.cf.imes.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.validation.InEnum;
|
||||
import com.cf.imes.module.system.validation.common.CommonStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -23,7 +22,7 @@ public class DictDataPageReqVO extends PageParam {
|
||||
private String dictType;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
||||
+5
-3
@@ -1,7 +1,6 @@
|
||||
package com.cf.imes.module.system.controller.admin.dict.vo.data;
|
||||
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.validation.InEnum;
|
||||
import com.cf.imes.module.system.validation.common.CommonStatus;
|
||||
import com.cf.imes.module.system.validation.dict.CssClassValid;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@@ -38,17 +37,20 @@ public class DictDataSaveReqVO {
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "颜色类型,default、primary、success、info、warning、danger", example = "default")
|
||||
@Size(max = 100, message = "颜色类型长度不能超过100个字符")
|
||||
private String colorType;
|
||||
|
||||
@Schema(description = "css 样式", example = "btn-visible")
|
||||
@CssClassValid
|
||||
@Size(max = 100, message = "css 样式长度不能超过100个字符")
|
||||
private String cssClass;
|
||||
|
||||
@Schema(description = "备注", example = "我是一个角色")
|
||||
@Size(max = 255, message = "备注长度不能超过255个字符")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -1,6 +1,7 @@
|
||||
package com.cf.imes.module.system.controller.admin.dict.vo.type;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.module.system.validation.common.CommonStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -17,6 +18,7 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
||||
public class DictTypePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "字典类型名称,模糊匹配", example = "晨丰")
|
||||
@Size(max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "字典类型,模糊匹配", example = "sys_common_sex")
|
||||
@@ -24,6 +26,7 @@ public class DictTypePageReqVO extends PageParam {
|
||||
private String type;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
|
||||
+3
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.system.controller.admin.dict.vo.type;
|
||||
|
||||
import com.cf.imes.module.system.validation.common.CommonStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -26,9 +27,11 @@ public class DictTypeSaveReqVO {
|
||||
|
||||
@Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "快乐的备注")
|
||||
@Size(max = 255, message = "备注长度不能超过255个字符")
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,11 +17,11 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
||||
public class LabelTemplatePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "标签类型", example = "2")
|
||||
@Size(max = 50, message = "标签类型长度不能超过50")
|
||||
@Size(max = 50, message = "标签类型长度不能超过50个字符")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "标签名称", example = "王五")
|
||||
@Size(max = 50, message = "标签名称长度不能超过50")
|
||||
@Size(max = 50, message = "标签名称长度不能超过50个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
|
||||
+3
-3
@@ -15,17 +15,17 @@ public class LabelTemplateSaveReqVO {
|
||||
|
||||
@Schema(description = "标签类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "标签类型不能为空")
|
||||
@Size(max = 50, message = "标签类型长度不能超过50")
|
||||
@Size(max = 50, message = "标签类型长度不能超过50个字符")
|
||||
private String type;
|
||||
|
||||
@Schema(description = "标签名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
|
||||
@NotEmpty(message = "标签名称不能为空")
|
||||
@Size(max = 50, message = "标签名称长度不能超过50")
|
||||
@Size(max = 50, message = "标签名称长度不能超过50个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||
@NotEmpty(message = "备注不能为空")
|
||||
@Size(max = 255, message = "备注长度不能超过255")
|
||||
@Size(max = 255, message = "备注长度不能超过255个字符")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class TenantPackageSaveReqVO {
|
||||
@Schema(description = "关联的菜单编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "关联的菜单编号不能为空")
|
||||
// todo 目前可用菜单数量大概在两百出头,暂时设置为300,后期扩展可以调整
|
||||
@Size(max = 300, message = "关联的菜单编号数量不能超过300")
|
||||
@Size(max = 300, message = "关联的菜单编号数量不能超过300个")
|
||||
private Set<Long> menuIds;
|
||||
|
||||
}
|
||||
|
||||
+6
@@ -1,18 +1,24 @@
|
||||
package com.cf.imes.module.system.controller.admin.permission.vo.menu;
|
||||
|
||||
import com.cf.imes.module.system.validation.common.CommonStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Schema(description = "管理后台 - 菜单列表 Request VO")
|
||||
@Data
|
||||
public class MenuListReqVO {
|
||||
|
||||
@Schema(description = "菜单名称,模糊匹配", example = "晨丰")
|
||||
@Size(max = 50, message = "菜单名称长度不能超过50个字符")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "菜单状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1")
|
||||
@CommonStatus
|
||||
private Integer visiable;
|
||||
}
|
||||
|
||||
+6
-1
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.module.system.controller.admin.permission.vo.menu;
|
||||
|
||||
import com.cf.imes.module.system.validation.common.CommonStatus;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -21,6 +22,7 @@ public class MenuSaveVO {
|
||||
|
||||
@Schema(description = "权限标识,仅菜单类型为按钮时,才需要传递", example = "sys:menu:add")
|
||||
@Size(max = 100)
|
||||
@Size(max = 100, message = "权限标识长度不能超过100个字符")
|
||||
private String permission;
|
||||
|
||||
@Schema(description = "类型,参见 MenuTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@@ -40,17 +42,20 @@ public class MenuSaveVO {
|
||||
private String path;
|
||||
|
||||
@Schema(description = "菜单图标,仅菜单类型为菜单或者目录时,才需要传", example = "/menu/list")
|
||||
@Size(max = 100, message = "菜单图标长度不能超过100个字符")
|
||||
private String icon;
|
||||
|
||||
@Schema(description = "组件路径,仅菜单类型为菜单时,才需要传", example = "system/post/index")
|
||||
@Size(max = 200, message = "组件路径不能超过255个字符")
|
||||
@Size(max = 255, message = "组件路径不能超过255个字符")
|
||||
private String component;
|
||||
|
||||
@Schema(description = "组件名", example = "SystemUser")
|
||||
@Size(max = 255, message = "组件名长度不能超过255个字符")
|
||||
private String componentName;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否可见", example = "false")
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public class PermissionAssignRoleMenuReqVO {
|
||||
|
||||
@Schema(description = "菜单编号列表", example = "1,3,5")
|
||||
// todo 目前可用菜单数量大概在两百出头,暂时设置为300,后期扩展可以调整
|
||||
@Size(max = 300, message = "关联的菜单编号数量不能超过300")
|
||||
@Size(max = 300, message = "关联的菜单编号数量不能超过300个")
|
||||
private Set<Long> menuIds = Collections.emptySet(); // 兜底
|
||||
|
||||
@Schema(description = "组织id")
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class PermissionAssignRoleUserReqVO {
|
||||
private Long roleId;
|
||||
|
||||
@Schema(description = "用户编号列表", example = "1,3,5")
|
||||
@Size(max = 300, message = "关联的用户编号数量不能超过300")
|
||||
@Size(max = 300, message = "关联的用户编号数量不能超过300个")
|
||||
private Set<Long> userIds = Collections.emptySet();
|
||||
|
||||
@Schema(description = "组织id")
|
||||
|
||||
+8
@@ -1,12 +1,16 @@
|
||||
package com.cf.imes.module.system.controller.admin.sms.vo.log;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.framework.common.validation.Mobile;
|
||||
import com.cf.imes.module.system.validation.sms.SmsReceiveStatusValid;
|
||||
import com.cf.imes.module.system.validation.sms.SmsSendStatusValid;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
@@ -24,9 +28,12 @@ public class SmsLogPageReqVO extends PageParam {
|
||||
private Long templateId;
|
||||
|
||||
@Schema(description = "手机号", example = "15601691300")
|
||||
@Mobile
|
||||
@Size(max = 11, message = "手机号长度不能超过 11 个字符")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "发送状态,参见 SmsSendStatusEnum 枚举类", example = "1")
|
||||
@SmsSendStatusValid
|
||||
private Integer sendStatus;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@@ -34,6 +41,7 @@ public class SmsLogPageReqVO extends PageParam {
|
||||
private LocalDateTime[] sendTime;
|
||||
|
||||
@Schema(description = "接收状态,参见 SmsReceiveStatusEnum 枚举类", example = "0")
|
||||
@SmsReceiveStatusValid
|
||||
private Integer receiveStatus;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
|
||||
+8
-4
@@ -1,12 +1,15 @@
|
||||
package com.cf.imes.module.system.controller.admin.sms.vo.template;
|
||||
|
||||
import com.cf.imes.framework.common.pojo.PageParam;
|
||||
import com.cf.imes.module.system.validation.common.CommonStatus;
|
||||
import com.cf.imes.module.system.validation.sms.SmsTemplateTypeValid;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
@@ -17,19 +20,20 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
||||
@ToString(callSuper = true)
|
||||
public class SmsTemplatePageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "短信签名", example = "1")
|
||||
@Schema(description = "短信模板类型", example = "1")
|
||||
@SmsTemplateTypeValid
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "开启状态", example = "1")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "模板编码,模糊匹配", example = "test_01")
|
||||
@Size(max = 64, message = "模板编码长度不能超过64个字符")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "模板内容,模糊匹配", example = "你好,{name}。你长的太{like}啦!")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "短信 API 的模板编号,模糊匹配", example = "4383920")
|
||||
@Size(max = 64, message = "短信 API 的模板编号长度不能超过64个字符")
|
||||
private String apiTemplateId;
|
||||
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
|
||||
+5
@@ -1,5 +1,7 @@
|
||||
package com.cf.imes.module.system.controller.admin.sms.vo.template;
|
||||
|
||||
import com.cf.imes.module.system.validation.common.CommonStatus;
|
||||
import com.cf.imes.module.system.validation.sms.SmsTemplateTypeValid;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@@ -15,10 +17,12 @@ public class SmsTemplateSaveReqVO {
|
||||
|
||||
@Schema(description = "短信类型,参见 SmsTemplateTypeEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "短信类型不能为空")
|
||||
@SmsTemplateTypeValid
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "开启状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "开启状态不能为空")
|
||||
@CommonStatus
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test_01")
|
||||
@@ -37,6 +41,7 @@ public class SmsTemplateSaveReqVO {
|
||||
private String content;
|
||||
|
||||
@Schema(description = "备注", example = "哈哈哈")
|
||||
@Length(max = 255, message = "备注长度不能超过255个字符")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "短信 API 的模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4383920")
|
||||
|
||||
+6
@@ -1,9 +1,11 @@
|
||||
package com.cf.imes.module.system.controller.admin.sms.vo.template;
|
||||
|
||||
import com.cf.imes.framework.common.validation.Mobile;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Map;
|
||||
|
||||
@Schema(description = "管理后台 - 短信模板的发送 Request VO")
|
||||
@@ -12,13 +14,17 @@ public class SmsTemplateSendReqVO {
|
||||
|
||||
@Schema(description = "手机号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15601691300")
|
||||
@NotNull(message = "手机号不能为空")
|
||||
@Mobile
|
||||
@Size(max = 11, message = "手机号长度不能超过11个字符")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test_01")
|
||||
@NotNull(message = "模板编码不能为空")
|
||||
@Size(max = 64, message = "模板编码长度不能超过64个字符")
|
||||
private String templateCode;
|
||||
|
||||
@Schema(description = "模板参数")
|
||||
@Size(max = 10, message = "模板参数数量不能超过10个")
|
||||
private Map<String, Object> templateParams;
|
||||
|
||||
}
|
||||
|
||||
-1
@@ -19,7 +19,6 @@ public interface SmsTemplateMapper extends BaseMapperX<SmsTemplateDO> {
|
||||
.eqIfPresent(SmsTemplateDO::getType, reqVO.getType())
|
||||
.eqIfPresent(SmsTemplateDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(SmsTemplateDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(SmsTemplateDO::getContent, reqVO.getContent())
|
||||
.likeIfPresent(SmsTemplateDO::getApiTemplateId, reqVO.getApiTemplateId())
|
||||
.betweenIfPresent(SmsTemplateDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(SmsTemplateDO::getId));
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cf.imes.module.system.validation.sms;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 短信接收状态校验注解
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/10/15 13:46
|
||||
*/
|
||||
@Target({
|
||||
ElementType.FIELD,
|
||||
})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(
|
||||
validatedBy = {SmsReceiveStatusValidator.class}
|
||||
)
|
||||
public @interface SmsReceiveStatusValid {
|
||||
String message() default "短信接收状态不合法";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.cf.imes.module.system.validation.sms;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.module.system.enums.sms.SmsReceiveStatusEnum;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* 短信接收状态校验器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/10/15 13:47
|
||||
*/
|
||||
public class SmsReceiveStatusValidator implements ConstraintValidator<SmsReceiveStatusValid, Integer> {
|
||||
@Override
|
||||
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
||||
if (ObjectUtil.isNull(value)) {
|
||||
return true;
|
||||
}
|
||||
for (SmsReceiveStatusEnum statusEnum : SmsReceiveStatusEnum.values()) {
|
||||
if (ObjectUtil.equal(statusEnum.getStatus(), value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cf.imes.module.system.validation.sms;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 短信发送状态校验注解
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/10/15 13:46
|
||||
*/
|
||||
@Target({
|
||||
ElementType.FIELD,
|
||||
})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(
|
||||
validatedBy = {SmsSendStatusValidator.class}
|
||||
)
|
||||
public @interface SmsSendStatusValid {
|
||||
String message() default "短信发送状态不合法";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.cf.imes.module.system.validation.sms;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.module.system.enums.sms.SmsSendStatusEnum;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* 短信发送状态校验器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/10/15 13:47
|
||||
*/
|
||||
public class SmsSendStatusValidator implements ConstraintValidator<SmsSendStatusValid, Integer> {
|
||||
@Override
|
||||
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
||||
if (ObjectUtil.isNull(value)) {
|
||||
return true;
|
||||
}
|
||||
for (SmsSendStatusEnum statusEnum : SmsSendStatusEnum.values()) {
|
||||
if (ObjectUtil.equal(statusEnum.getStatus(), value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cf.imes.module.system.validation.sms;
|
||||
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 短信模版校验注解
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/10/15 13:46
|
||||
*/
|
||||
@Target({
|
||||
ElementType.FIELD,
|
||||
})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Constraint(
|
||||
validatedBy = {SmsTemplateTypeValidator.class}
|
||||
)
|
||||
public @interface SmsTemplateTypeValid {
|
||||
String message() default "短信模板类型不合法";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default {};
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.cf.imes.module.system.validation.sms;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.module.system.enums.sms.SmsTemplateTypeEnum;
|
||||
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
/**
|
||||
* 短信模版校验器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/10/15 13:47
|
||||
*/
|
||||
public class SmsTemplateTypeValidator implements ConstraintValidator<SmsTemplateTypeValid, Integer> {
|
||||
@Override
|
||||
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
||||
if (ObjectUtil.isNull(value)) {
|
||||
return true;
|
||||
}
|
||||
for (SmsTemplateTypeEnum templateTypeEnum : SmsTemplateTypeEnum.values()) {
|
||||
if (ObjectUtil.equal(templateTypeEnum.getType(), value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-1
@@ -217,7 +217,6 @@ public class SmsTemplateServiceImplTest extends BaseDbUnitTest {
|
||||
reqVO.setType(SmsTemplateTypeEnum.PROMOTION.getType());
|
||||
reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||
reqVO.setCode("tu");
|
||||
reqVO.setContent("晨丰");
|
||||
reqVO.setApiTemplateId("yu");
|
||||
reqVO.setCreateTime(buildBetweenTime(2021, 11, 1, 2021, 12, 1));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user