mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
余料字段校验、用户查询修改
This commit is contained in:
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package com.cf.imes.module.manage.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 余料板放置枚举类
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum RemainPlatePlaceStyleEnum {
|
||||||
|
|
||||||
|
ZERO(0, "正面"),
|
||||||
|
ONE(1, "正面右转"),
|
||||||
|
TWO(2, "正面后转"),
|
||||||
|
THREE(3, "正面左转"),
|
||||||
|
FOUR(4, "反面"),
|
||||||
|
FIVE(5, "反面右转"),
|
||||||
|
SIX(6, "反面后转"),
|
||||||
|
SEVEN(7, "反面左转");
|
||||||
|
|
||||||
|
private final Integer status;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public boolean equals(Integer status) {
|
||||||
|
return this.status .equals(status) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(RemainPlatePlaceStyleEnum enableStatusEnum) {
|
||||||
|
return enableStatusEnum != null && enableStatusEnum.status .equals(this.getStatus()) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -7,7 +7,7 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum RemainPlateStatusEnum {
|
public enum RemainPlateStatusEnum {
|
||||||
UNUSED(0, "未使用"),
|
UNUSED(0, "未使用"),
|
||||||
IN_USE(1, "使用中");
|
USED(1, "已使用");
|
||||||
|
|
||||||
private final Integer status;
|
private final Integer status;
|
||||||
private String description;
|
private String description;
|
||||||
|
|||||||
+4
-8
@@ -1,8 +1,6 @@
|
|||||||
package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
|
package com.cf.imes.module.manage.controller.admin.plate.vo.plate;
|
||||||
|
|
||||||
import com.cf.imes.module.manage.validation.length.ValidLength;
|
import com.cf.imes.framework.common.validation.NumberValid;
|
||||||
import com.cf.imes.module.manage.validation.longConvert.ValidLong;
|
|
||||||
import com.cf.imes.module.manage.validation.texture.ValidBoolean;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
@@ -38,22 +36,21 @@ public class PlateSaveReqVO {
|
|||||||
private String color;
|
private String color;
|
||||||
|
|
||||||
@Schema(description = "纹理", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "纹理", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ValidBoolean
|
|
||||||
private Boolean texture;
|
private Boolean texture;
|
||||||
|
|
||||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "宽度不能为空")
|
@NotNull(message = "宽度不能为空")
|
||||||
@ValidLength()
|
@NumberValid(name = "宽度")
|
||||||
private Double width;
|
private Double width;
|
||||||
|
|
||||||
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "高度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "高度不能为空")
|
@NotNull(message = "高度不能为空")
|
||||||
@ValidLength()
|
@NumberValid(name = "高度")
|
||||||
private Double height;
|
private Double height;
|
||||||
|
|
||||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "厚度不能为空")
|
@NotNull(message = "厚度不能为空")
|
||||||
@ValidLength()
|
@NumberValid(name = "厚度")
|
||||||
private Double thickness;
|
private Double thickness;
|
||||||
|
|
||||||
// @Schema(description = "价格", example = "3380")
|
// @Schema(description = "价格", example = "3380")
|
||||||
@@ -71,6 +68,5 @@ public class PlateSaveReqVO {
|
|||||||
@Size(max = 255, message = "备注长度不能超过255个字符")
|
@Size(max = 255, message = "备注长度不能超过255个字符")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@ValidLong
|
|
||||||
private Long organId;
|
private Long organId;
|
||||||
}
|
}
|
||||||
+2
-1
@@ -1,7 +1,7 @@
|
|||||||
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
|
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.validation.NumberValid;
|
||||||
import com.cf.imes.module.manage.validation.common.ValidCommonStatus;
|
import com.cf.imes.module.manage.validation.common.ValidCommonStatus;
|
||||||
import com.cf.imes.module.manage.validation.length.ValidLength;
|
|
||||||
import com.cf.imes.module.manage.validation.placeStyle.ValidPlaceStyle;
|
import com.cf.imes.module.manage.validation.placeStyle.ValidPlaceStyle;
|
||||||
import com.cf.imes.module.manage.validation.type.ValidTypeField;
|
import com.cf.imes.module.manage.validation.type.ValidTypeField;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
@@ -70,6 +70,7 @@ public class RemainPlatePageReqVO extends PageParam {
|
|||||||
private BigDecimal[] length;
|
private BigDecimal[] length;
|
||||||
|
|
||||||
@Schema(description = "厚度")
|
@Schema(description = "厚度")
|
||||||
|
@NumberValid(name = "厚度")
|
||||||
private BigDecimal thickness;
|
private BigDecimal thickness;
|
||||||
|
|
||||||
@Schema(description = "品牌")
|
@Schema(description = "品牌")
|
||||||
|
|||||||
+4
-8
@@ -1,8 +1,7 @@
|
|||||||
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
|
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.validation.NumberValid;
|
||||||
import com.cf.imes.module.manage.validation.common.ValidCommonStatus;
|
import com.cf.imes.module.manage.validation.common.ValidCommonStatus;
|
||||||
import com.cf.imes.module.manage.validation.length.ValidLength;
|
|
||||||
import com.cf.imes.module.manage.validation.nonZero.ValidNonZero;
|
|
||||||
import com.cf.imes.module.manage.validation.placeStyle.ValidPlaceStyle;
|
import com.cf.imes.module.manage.validation.placeStyle.ValidPlaceStyle;
|
||||||
import com.cf.imes.module.manage.validation.type.ValidTypeField;
|
import com.cf.imes.module.manage.validation.type.ValidTypeField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
@@ -63,20 +62,17 @@ public class RemainPlateSaveReqVO {
|
|||||||
|
|
||||||
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "宽度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "宽度不能为空")
|
@NotNull(message = "宽度不能为空")
|
||||||
@ValidLength
|
@NumberValid(name = "宽度")
|
||||||
@ValidNonZero
|
|
||||||
private BigDecimal width;
|
private BigDecimal width;
|
||||||
|
|
||||||
@Schema(description = "长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "长度不能为空")
|
@NotNull(message = "长度不能为空")
|
||||||
@ValidLength
|
@NumberValid(name = "长度")
|
||||||
@ValidNonZero
|
|
||||||
private BigDecimal length;
|
private BigDecimal length;
|
||||||
|
|
||||||
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "厚度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "厚度不能为空")
|
@NotNull(message = "厚度不能为空")
|
||||||
@ValidLength
|
@NumberValid(name = "厚度")
|
||||||
@ValidNonZero
|
|
||||||
private BigDecimal thickness;
|
private BigDecimal thickness;
|
||||||
|
|
||||||
@Schema(description = "品牌")
|
@Schema(description = "品牌")
|
||||||
|
|||||||
+5
-5
@@ -72,7 +72,7 @@ public class RemainPlateServiceImpl implements RemainPlateService {
|
|||||||
validateRemainPlateExists(ids);
|
validateRemainPlateExists(ids);
|
||||||
if (useType != RemainPlateUseTypeEnum.TYPE_ONE.getStatus() && useType != RemainPlateUseTypeEnum.TYPE_ZERO.getStatus()) { //余料使用状态为2或3
|
if (useType != RemainPlateUseTypeEnum.TYPE_ONE.getStatus() && useType != RemainPlateUseTypeEnum.TYPE_ZERO.getStatus()) { //余料使用状态为2或3
|
||||||
// 判断该排单是否存在以使用的余料
|
// 判断该排单是否存在以使用的余料
|
||||||
if (remainPlateMapper.selectRemainPlatesByPlanId(planId, RemainPlateStatusEnum.IN_USE.getStatus(),
|
if (remainPlateMapper.selectRemainPlatesByPlanId(planId, RemainPlateStatusEnum.USED.getStatus(),
|
||||||
DeletedCodeEnum.NOT_DELETED.getStatus(), OrganContextHolder.getOrganId()).size() > 0) {
|
DeletedCodeEnum.NOT_DELETED.getStatus(), OrganContextHolder.getOrganId()).size() > 0) {
|
||||||
// 余料状态还原
|
// 余料状态还原
|
||||||
remainPlateMapper.updateRemainPlateStatusByPlanId(RemainPlateStatusEnum.UNUSED.getStatus(), RemainPlateUseTypeEnum.TYPE_ZERO.getStatus(),
|
remainPlateMapper.updateRemainPlateStatusByPlanId(RemainPlateStatusEnum.UNUSED.getStatus(), RemainPlateUseTypeEnum.TYPE_ZERO.getStatus(),
|
||||||
@@ -81,7 +81,7 @@ public class RemainPlateServiceImpl implements RemainPlateService {
|
|||||||
}
|
}
|
||||||
if (ids != null){
|
if (ids != null){
|
||||||
//判断是否符合核销标准
|
//判断是否符合核销标准
|
||||||
validateRemainPlateStatus(ids, RemainPlateStatusEnum.IN_USE.getStatus());
|
validateRemainPlateStatus(ids, RemainPlateStatusEnum.USED.getStatus());
|
||||||
//以id为条件批量修改余料库中的状态
|
//以id为条件批量修改余料库中的状态
|
||||||
remainPlateMapper.updateRemainPlateStatus(ids, status, useType, OrganContextHolder.getOrganId(), planId);
|
remainPlateMapper.updateRemainPlateStatus(ids, status, useType, OrganContextHolder.getOrganId(), planId);
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ public class RemainPlateServiceImpl implements RemainPlateService {
|
|||||||
// 校验存在
|
// 校验存在
|
||||||
validateRemainPlateExists(updateReqVO.getId());
|
validateRemainPlateExists(updateReqVO.getId());
|
||||||
// 是否使用
|
// 是否使用
|
||||||
if (validateRemainPlateStatus(updateReqVO.getId()) == RemainPlateStatusEnum.IN_USE.getStatus()) {
|
if (validateRemainPlateStatus(updateReqVO.getId()) == RemainPlateStatusEnum.USED.getStatus()) {
|
||||||
throw exception(REMAIN_PLATE_STATUS_USED);
|
throw exception(REMAIN_PLATE_STATUS_USED);
|
||||||
}
|
}
|
||||||
// 判断是否为开料添加
|
// 判断是否为开料添加
|
||||||
@@ -132,7 +132,7 @@ public class RemainPlateServiceImpl implements RemainPlateService {
|
|||||||
// 余料存在判断
|
// 余料存在判断
|
||||||
validateRemainPlateExists(ids);
|
validateRemainPlateExists(ids);
|
||||||
// 判断余料的状态是否存在使用中
|
// 判断余料的状态是否存在使用中
|
||||||
validateRemainPlateStatus(ids, RemainPlateStatusEnum.IN_USE.getStatus());
|
validateRemainPlateStatus(ids, RemainPlateStatusEnum.USED.getStatus());
|
||||||
// 删除
|
// 删除
|
||||||
remainPlateMapper.deleteBatchIds(ids);
|
remainPlateMapper.deleteBatchIds(ids);
|
||||||
}
|
}
|
||||||
@@ -141,7 +141,7 @@ public class RemainPlateServiceImpl implements RemainPlateService {
|
|||||||
private void validateRemainPlateStatus(Set<Long> ids, Integer status) {
|
private void validateRemainPlateStatus(Set<Long> ids, Integer status) {
|
||||||
for (Long id : ids) {
|
for (Long id : ids) {
|
||||||
if (validateRemainPlateStatus(id) == status) {
|
if (validateRemainPlateStatus(id) == status) {
|
||||||
if (status == RemainPlateStatusEnum.IN_USE.getStatus())
|
if (status == RemainPlateStatusEnum.USED.getStatus())
|
||||||
throw exception(REMAIN_PLATE_STATUS_USED);
|
throw exception(REMAIN_PLATE_STATUS_USED);
|
||||||
if (status == RemainPlateStatusEnum.UNUSED.getStatus())
|
if (status == RemainPlateStatusEnum.UNUSED.getStatus())
|
||||||
throw exception(REMAIN_PLATE_STATUS_NO_USED);
|
throw exception(REMAIN_PLATE_STATUS_NO_USED);
|
||||||
|
|||||||
+12
-1
@@ -2,14 +2,25 @@ package com.cf.imes.module.manage.validation.common;
|
|||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
import javax.validation.ConstraintValidator;
|
||||||
import javax.validation.ConstraintValidatorContext;
|
import javax.validation.ConstraintValidatorContext;
|
||||||
|
import com.cf.imes.module.manage.enums.RemainPlateStatusEnum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态校验
|
* 状态校验
|
||||||
*/
|
*/
|
||||||
public class CommonStatusValidator implements ConstraintValidator<ValidCommonStatus, Integer> {
|
public class CommonStatusValidator implements ConstraintValidator<ValidCommonStatus, Integer> {
|
||||||
|
|
||||||
|
private ValidCommonStatus annotation;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ValidCommonStatus constraintAnnotation) {
|
||||||
|
this.annotation = constraintAnnotation;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
||||||
return value == null || (value == 0 || value == 1);
|
if (value == null) {
|
||||||
|
value = RemainPlateStatusEnum.UNUSED.getStatus(); // 默认值为未使用
|
||||||
|
}
|
||||||
|
return value == RemainPlateStatusEnum.UNUSED.getStatus() || value == RemainPlateStatusEnum.USED.getStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
package com.cf.imes.module.manage.validation.length;
|
|
||||||
|
|
||||||
import javax.validation.Constraint;
|
|
||||||
import javax.validation.Payload;
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字长度校验器注解
|
|
||||||
*/
|
|
||||||
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Constraint(validatedBy = WidthLengthValidator.class)
|
|
||||||
@Documented
|
|
||||||
public @interface ValidLength {
|
|
||||||
String message() default "数值长度不符合";
|
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
|
||||||
|
|
||||||
int maxDigits() default 8; // 最大总位数
|
|
||||||
int maxFractionalDigits() default 3; // 小数点后的最大位数
|
|
||||||
}
|
|
||||||
-36
@@ -1,36 +0,0 @@
|
|||||||
package com.cf.imes.module.manage.validation.length;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
|
||||||
import javax.validation.ConstraintValidatorContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数字长度校验器
|
|
||||||
*/
|
|
||||||
public class WidthLengthValidator implements ConstraintValidator<ValidLength, Double> {
|
|
||||||
|
|
||||||
private int maxDigits;
|
|
||||||
private int maxFractionalDigits;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize(ValidLength constraintAnnotation) {
|
|
||||||
this.maxDigits = constraintAnnotation.maxDigits();
|
|
||||||
this.maxFractionalDigits = constraintAnnotation.maxFractionalDigits();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(Double value, ConstraintValidatorContext context) {
|
|
||||||
if (value == null) {
|
|
||||||
return true; // 允许 null 值
|
|
||||||
}
|
|
||||||
String valueAsString = Double.toString(value);
|
|
||||||
int decimalPointIndex = valueAsString.indexOf('.');
|
|
||||||
|
|
||||||
// 计算整数部分和小数部分的位数
|
|
||||||
int integerPartLength = decimalPointIndex == -1 ? valueAsString.length() : decimalPointIndex;
|
|
||||||
int fractionalPartLength = decimalPointIndex == -1 ? 0 : valueAsString.length() - decimalPointIndex - 1;
|
|
||||||
|
|
||||||
int totalDigits = integerPartLength + fractionalPartLength;
|
|
||||||
|
|
||||||
return totalDigits <= maxDigits && fractionalPartLength <= maxFractionalDigits;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package com.cf.imes.module.manage.validation.longConvert;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
|
||||||
import javax.validation.ConstraintValidatorContext;
|
|
||||||
|
|
||||||
public class LongValidator implements ConstraintValidator<ValidLong, String> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(String value, ConstraintValidatorContext context) {
|
|
||||||
if (value == null) {
|
|
||||||
return true; // 允许 null 值
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Long.parseLong(value);
|
|
||||||
return true;
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package com.cf.imes.module.manage.validation.longConvert;
|
|
||||||
|
|
||||||
import javax.validation.Constraint;
|
|
||||||
import javax.validation.Payload;
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
|
|
||||||
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Constraint(validatedBy = LongValidator.class)
|
|
||||||
@Documented
|
|
||||||
public @interface ValidLong {
|
|
||||||
|
|
||||||
String message() default "ID参数类型有误";
|
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
|
||||||
|
|
||||||
}
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
package com.cf.imes.module.manage.validation.nonZero;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
|
||||||
import javax.validation.ConstraintValidatorContext;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数值大于0校验
|
|
||||||
*/
|
|
||||||
public class NonNegativeValidator implements ConstraintValidator<ValidNonZero, BigDecimal> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(BigDecimal value, ConstraintValidatorContext context) {
|
|
||||||
return value == null || value.signum() >= 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
package com.cf.imes.module.manage.validation.nonZero;
|
|
||||||
|
|
||||||
import javax.validation.Constraint;
|
|
||||||
import javax.validation.Payload;
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数值大于0校验注解
|
|
||||||
*/
|
|
||||||
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Constraint(validatedBy = NonNegativeValidator.class)
|
|
||||||
@Documented
|
|
||||||
public @interface ValidNonZero {
|
|
||||||
|
|
||||||
String message() default "长度数值必须大于等于0";
|
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
|
||||||
}
|
|
||||||
+20
-2
@@ -1,5 +1,7 @@
|
|||||||
package com.cf.imes.module.manage.validation.placeStyle;
|
package com.cf.imes.module.manage.validation.placeStyle;
|
||||||
|
|
||||||
|
import com.cf.imes.module.manage.enums.RemainPlatePlaceStyleEnum;
|
||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
import javax.validation.ConstraintValidator;
|
||||||
import javax.validation.ConstraintValidatorContext;
|
import javax.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
@@ -8,9 +10,25 @@ import javax.validation.ConstraintValidatorContext;
|
|||||||
*/
|
*/
|
||||||
public class PlaceStyleValidator implements ConstraintValidator<ValidPlaceStyle, Integer> {
|
public class PlaceStyleValidator implements ConstraintValidator<ValidPlaceStyle, Integer> {
|
||||||
|
|
||||||
|
private ValidPlaceStyle annotation;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ValidPlaceStyle constraintAnnotation) {
|
||||||
|
this.annotation = constraintAnnotation;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
||||||
return value == null || (value == 0 || value == 1 || value == 2 || value == 3
|
if (value == null) {
|
||||||
|| value == 4 || value == 5 || value == 6 || value == 7);
|
value = RemainPlatePlaceStyleEnum.ZERO.getStatus(); // 默认值为正面
|
||||||
|
}
|
||||||
|
return value == RemainPlatePlaceStyleEnum.ONE.getStatus()
|
||||||
|
|| value == RemainPlatePlaceStyleEnum.TWO.getStatus()
|
||||||
|
|| value == RemainPlatePlaceStyleEnum.THREE.getStatus()
|
||||||
|
|| value == RemainPlatePlaceStyleEnum.FOUR.getStatus()
|
||||||
|
|| value == RemainPlatePlaceStyleEnum.FIVE.getStatus()
|
||||||
|
|| value == RemainPlatePlaceStyleEnum.SIX.getStatus()
|
||||||
|
|| value == RemainPlatePlaceStyleEnum.SEVEN.getStatus()
|
||||||
|
|| value == RemainPlatePlaceStyleEnum.ZERO.getStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -1,6 +1,5 @@
|
|||||||
package com.cf.imes.module.manage.validation.placeStyle;
|
package com.cf.imes.module.manage.validation.placeStyle;
|
||||||
|
|
||||||
import com.cf.imes.module.manage.validation.texture.BooleanTypeValidator;
|
|
||||||
|
|
||||||
import javax.validation.Constraint;
|
import javax.validation.Constraint;
|
||||||
import javax.validation.Payload;
|
import javax.validation.Payload;
|
||||||
|
|||||||
-21
@@ -1,21 +0,0 @@
|
|||||||
package com.cf.imes.module.manage.validation.texture;
|
|
||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
|
||||||
import javax.validation.ConstraintValidatorContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 纹理校验
|
|
||||||
*/
|
|
||||||
public class BooleanTypeValidator implements ConstraintValidator<ValidBoolean, String> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid(String value, ConstraintValidatorContext context) {
|
|
||||||
if (value == null) {
|
|
||||||
return true; // 允许 null 值
|
|
||||||
}
|
|
||||||
return value.equalsIgnoreCase("true") ||
|
|
||||||
value.equalsIgnoreCase("false") ||
|
|
||||||
value.equals("0") ||
|
|
||||||
value.equals("1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
package com.cf.imes.module.manage.validation.texture;
|
|
||||||
|
|
||||||
import javax.validation.Constraint;
|
|
||||||
import javax.validation.Payload;
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
/**
|
|
||||||
* 纹理校验注解
|
|
||||||
*/
|
|
||||||
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Constraint(validatedBy = BooleanTypeValidator.class)
|
|
||||||
@Documented
|
|
||||||
public @interface ValidBoolean {
|
|
||||||
|
|
||||||
String message() default "纹理不合法,1:有、0:无";
|
|
||||||
|
|
||||||
Class<?>[] groups() default {};
|
|
||||||
|
|
||||||
Class<? extends Payload>[] payload() default {};
|
|
||||||
}
|
|
||||||
+17
-1
@@ -1,5 +1,7 @@
|
|||||||
package com.cf.imes.module.manage.validation.type;
|
package com.cf.imes.module.manage.validation.type;
|
||||||
|
|
||||||
|
import com.cf.imes.module.manage.enums.RemainPlateUseTypeEnum;
|
||||||
|
|
||||||
import javax.validation.ConstraintValidator;
|
import javax.validation.ConstraintValidator;
|
||||||
import javax.validation.ConstraintValidatorContext;
|
import javax.validation.ConstraintValidatorContext;
|
||||||
|
|
||||||
@@ -8,8 +10,22 @@ import javax.validation.ConstraintValidatorContext;
|
|||||||
*/
|
*/
|
||||||
public class TypeFieldValidator implements ConstraintValidator<ValidTypeField, Integer> {
|
public class TypeFieldValidator implements ConstraintValidator<ValidTypeField, Integer> {
|
||||||
|
|
||||||
|
private ValidTypeField annotation;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(ValidTypeField constraintAnnotation) {
|
||||||
|
this.annotation = constraintAnnotation;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
public boolean isValid(Integer value, ConstraintValidatorContext context) {
|
||||||
return value == null || (value == 0 || value == 1 || value == 2);
|
// 如果值为 null,则不做校验,直接返回 true
|
||||||
|
if (value == null) {
|
||||||
|
value = RemainPlateUseTypeEnum.TYPE_ZERO.getStatus(); // 默认值为未使用
|
||||||
|
}
|
||||||
|
return value == RemainPlateUseTypeEnum.TYPE_ONE.getStatus() ||
|
||||||
|
value == RemainPlateUseTypeEnum.TYPE_TWO.getStatus() ||
|
||||||
|
value == RemainPlateUseTypeEnum.TYPE_THREE.getStatus() ||
|
||||||
|
value == RemainPlateUseTypeEnum.TYPE_ZERO.getStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -77,7 +77,7 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
|
|||||||
lambdaQueryWrapperX.eqIfPresent(AdminUserDO::getOrganId, loginUser.getOrganId());
|
lambdaQueryWrapperX.eqIfPresent(AdminUserDO::getOrganId, loginUser.getOrganId());
|
||||||
}
|
}
|
||||||
return selectPage(reqVO, lambdaQueryWrapperX
|
return selectPage(reqVO, lambdaQueryWrapperX
|
||||||
.likeIfPresent(AdminUserDO::getUsername, reqVO.getMobile())
|
.likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername())
|
||||||
.eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus())
|
.eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus())
|
||||||
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.inIfPresent(AdminUserDO::getDeptId, deptIds)
|
.inIfPresent(AdminUserDO::getDeptId, deptIds)
|
||||||
|
|||||||
Reference in New Issue
Block a user