Commit 214a162d by s_guodong

拦截0,0.0

parent 06522649
......@@ -84,6 +84,16 @@ public class ValidatorUtil {
}
if (f.isAnnotationPresent(Need.class)) {
Need annotation = f.getAnnotation(Need.class);
String flg = annotation.flg();
// 拦截0, 0.00的情况
if ("1".equals(flg)) {
if (type.isAssignableFrom(BigDecimal.class) && o != null) {
BigDecimal bigDecimal = (BigDecimal) o;
if (bigDecimal.compareTo(BigDecimal.ZERO) == 0) {
return "参数校验错误[" + annotation.message() + "]";
}
}
}
if (o == null) {
return "参数校验错误[" + annotation.message() + "]";
}
......
......@@ -12,5 +12,7 @@ public @interface Need {
boolean value() default true;
String flg() default "";
String message() default "必填项不能为空";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment