mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-06-25 14:37:40 +08:00
代码生成器
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.hxkj.common.validator;
|
||||
|
||||
import com.hxkj.common.validator.annotation.IntArrayEmpty;
|
||||
import javax.validation.ConstraintValidator;
|
||||
import javax.validation.ConstraintValidatorContext;
|
||||
|
||||
|
||||
/**
|
||||
* 验证整数数组是否为空
|
||||
*/
|
||||
public class IntArrayEmptyValidator implements ConstraintValidator<IntArrayEmpty, int[]> {
|
||||
|
||||
@Override
|
||||
public void initialize(IntArrayEmpty constraintAnnotation) {
|
||||
ConstraintValidator.super.initialize(constraintAnnotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(int[] value, ConstraintValidatorContext context) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return value.length > 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.hxkj.common.validator.annotation;
|
||||
|
||||
import com.hxkj.common.validator.IntArrayEmptyValidator;
|
||||
import javax.validation.Constraint;
|
||||
import javax.validation.Payload;
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
@Constraint(validatedBy = IntArrayEmptyValidator.class)
|
||||
@Target({ ElementType.PARAMETER,ElementType.FIELD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface IntArrayEmpty {
|
||||
|
||||
String message() default "数组不允许为空";
|
||||
|
||||
Class<?>[] groups() default {};
|
||||
|
||||
Class<? extends Payload>[] payload() default { };
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user