1.校验修改

This commit is contained in:
2024-12-06 16:37:48 +08:00
parent 932ab2d6f5
commit da3e897fc2
2 changed files with 10 additions and 8 deletions

View File

@@ -229,6 +229,11 @@ public interface PatternRegex {
*/ */
String POSITIVE = "^[0-9].*$"; String POSITIVE = "^[0-9].*$";
/**
* 大于0的数字整数以及小数
*/
String POSITIVEALL_NUM = "^(?:[1-9]\\d*(\\.\\d+)?)$";
/** /**
* 资源名称 * 资源名称
*/ */

View File

@@ -6,10 +6,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.hibernate.validator.constraints.Range; import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.Min; import javax.validation.constraints.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/** /**
* 线路信息表 * 线路信息表
@@ -68,7 +65,7 @@ public class LineParam {
*/ */
@ApiModelProperty(name = "devCapacity",value = "设备容量",required = true) @ApiModelProperty(name = "devCapacity",value = "设备容量",required = true)
@NotNull(message = "设备容量不可为空") @NotNull(message = "设备容量不可为空")
@Min(value = 1,message = "设备容量格式有误") @Pattern(regexp=PatternRegex.POSITIVEALL_NUM,message = "设备容量格式有误")
private Float devCapacity; private Float devCapacity;
/** /**
@@ -76,7 +73,7 @@ public class LineParam {
*/ */
@ApiModelProperty(name = "shortCapacity",value = "短路容量",required = true) @ApiModelProperty(name = "shortCapacity",value = "短路容量",required = true)
@NotNull(message = "短路容量不可为空") @NotNull(message = "短路容量不可为空")
@Min(value = 1,message = "设备容量格式有误") @Pattern(regexp=PatternRegex.POSITIVEALL_NUM,message = "短路容量格式有误")
private Float shortCapacity; private Float shortCapacity;
/** /**
@@ -84,7 +81,7 @@ public class LineParam {
*/ */
@ApiModelProperty(name = "dealCapacity",value = "协议容量",required = true) @ApiModelProperty(name = "dealCapacity",value = "协议容量",required = true)
@NotNull(message = "协议容量不可为空") @NotNull(message = "协议容量不可为空")
@Min(value = 1,message = "设备容量格式有误") @Pattern(regexp=PatternRegex.POSITIVEALL_NUM,message = "协议容量格式有误")
private Float dealCapacity; private Float dealCapacity;
/** /**
@@ -92,7 +89,7 @@ public class LineParam {
*/ */
@ApiModelProperty(name = "standardCapacity",value = "基准容量新增时候可为空",required = true) @ApiModelProperty(name = "standardCapacity",value = "基准容量新增时候可为空",required = true)
@NotNull(message = "基准容量不可为空") @NotNull(message = "基准容量不可为空")
@Min(value = 1,message = "设备容量格式有误") @Pattern(regexp=PatternRegex.POSITIVEALL_NUM,message = "基准容量格式有误")
private Float standardCapacity; private Float standardCapacity;