系统基础模块:请求入参校验对齐数据库长度限制,主要针对String类型

This commit is contained in:
gaoqr
2024-09-27 17:15:57 +08:00
parent 360efa0421
commit 4f33449cf1
7 changed files with 30 additions and 5 deletions
@@ -5,7 +5,9 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
@@ -29,6 +31,8 @@ public class ReportDatasetSaveReqVO implements Serializable {
private Long id;
@Schema(description = "数据集名称", example = "测试数据集")
@NotBlank
@Length(min = 1, max = 64, message = "数据集名称长度不能超过64个字符")
private String name;
@Schema(description = "数据源id", example = "1")
@@ -39,6 +43,7 @@ public class ReportDatasetSaveReqVO implements Serializable {
private String sql;
@Schema(description = "bean数据源方法名")
@Length(min = 1, max = 64, message = "bean数据源方法名长度不能超过64个字符")
private String method;
@Schema(description = "参数列表")
@@ -1,18 +1,17 @@
package com.cf.imes.module.report.controller.admin.datasource.vo;
import com.cf.imes.module.report.controller.admin.dataset.vo.ReportDatasetSaveReqVO;
import com.cf.imes.module.report.validation.datasource.ReportDatasourceTypeInEnum;
import com.cf.imes.module.report.validation.template.ReportTemplateTypeInEnum;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -33,6 +32,8 @@ public class ReportDatasourceSaveReqVO implements Serializable {
private Long id;
@Schema(description = "数据源名称", example = "测试库")
@NotBlank
@Length(min = 1, max = 64, message = "数据源名称长度不能超过64个字符")
private String name;
@Schema(description = "数据源类型,jdbc、spring、api", example = "1")
@@ -44,18 +45,23 @@ public class ReportDatasourceSaveReqVO implements Serializable {
private Integer buildinType;
@Schema(description = "spring型数据源id")
@Length(max = 64, message = "spring型数据源id长度不能超过64个字符")
private String beanId;
@Schema(description = "数据源驱动类",example = "com.mysql.cj.jdbc.Driver")
@Length(max = 64, message = "数据源驱动类长度不能超过64个字符")
private String driver;
@Schema(description = "数据源地址", example = "https://www.cf.com")
@Length(max = 255, message = "数据源地址长度不能超过255个字符")
private String url;
@Schema(description = "数据源用户名", example = "晨丰")
@Length(max = 64, message = "数据源用户名长度不能超过64个字符")
private String username;
@Schema(description = "数据源密码", example = "晨丰")
@Length(max = 64, message = "数据源密码长度不能超过64个字符")
private String password;
@Schema(description = "备注", example = "该模板仅供生产使用")
@@ -5,8 +5,9 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import java.util.List;
import javax.validation.constraints.NotBlank;
import java.util.Set;
/**
@@ -24,6 +25,8 @@ public class ReportTemplateSaveReqVO {
private Long id;
@Schema(description = "模板名称", example = "生产单模板")
@NotBlank
@Length(min = 1, max = 30, message = "模板名称长度不能超过30个字符")
private String name;
@Schema(description = "报表模板")
@@ -4,6 +4,7 @@ import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.common.validation.InEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@@ -17,10 +18,12 @@ public class NotifyTemplateSaveReqVO {
@Schema(description = "模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试模版")
@NotEmpty(message = "模版名称不能为空")
@Length(min = 1, max = 64, message = "模版名称长度不能超过64个字符")
private String name;
@Schema(description = "模版编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "SEND_TEST")
@NotNull(message = "模版编码不能为空")
@Length(min = 1, max = 64, message = "模版编码长度不能超过64个字符")
private String code;
@Schema(description = "模版类型,对应 system_notify_template_type 字典", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@@ -29,10 +32,12 @@ public class NotifyTemplateSaveReqVO {
@Schema(description = "发送人名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆")
@NotEmpty(message = "发送人名称不能为空")
@Length(min = 1, max = 255, message = "发送人名称长度不能超过255个字符")
private String nickname;
@Schema(description = "模版内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是模版内容")
@NotEmpty(message = "模版内容不能为空")
@Length(min = 1, max = 1024, message = "模版内容长度不能超过1024个字符")
private String content;
@Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@@ -19,6 +19,7 @@ public class OrganSaveReqVO {
@Schema(description = "组织名", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
@NotNull(message = "组织名不能为空")
@Length(min = 1, max = 30, message = "组织名长度不能超过30个字符")
private String name;
@Schema(description = "联系人", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
@@ -19,7 +19,7 @@ public class TenantPackageSaveReqVO {
@Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "VIP")
@NotEmpty(message = "套餐名不能为空")
@Length(min = 1, max = 30, message = "套餐名长度不能超过30")
@Length(min = 1, max = 30, message = "套餐名长度不能超过30个字符")
private String name;
@Schema(description = "状态,参见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.controller.admin.sms.vo.template;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull;
@@ -22,14 +23,17 @@ public class SmsTemplateSaveReqVO {
@Schema(description = "模板编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "test_01")
@NotNull(message = "模板编码不能为空")
@Length(min = 1, max = 64, message = "模板编码长度不能超过64个字符")
private String code;
@Schema(description = "模板名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "chenfeng")
@NotNull(message = "模板名称不能为空")
@Length(min = 1, max = 64, message = "模板名称长度不能超过64个字符")
private String name;
@Schema(description = "模板内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "你好,{name}。你长的太{like}啦!")
@NotNull(message = "模板内容不能为空")
@Length(min = 1, max = 255, message = "模板内容长度不能超过255个字符")
private String content;
@Schema(description = "备注", example = "哈哈哈")
@@ -37,6 +41,7 @@ public class SmsTemplateSaveReqVO {
@Schema(description = "短信 API 的模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4383920")
@NotNull(message = "短信 API 的模板编号不能为空")
@Length(min = 1, max = 64, message = "短信 API 的模板编号长度不能超过64个字符")
private String apiTemplateId;
@Schema(description = "短信渠道编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")