Commit a3187b94 by s_guodong

BigDecimal参数校验优化

parent 8404467e
......@@ -41,7 +41,7 @@ public class ValidatorUtil {
return "参数校验错误[" + f.getName() + ":" + message + "]";
}
} else if (type.isAssignableFrom(BigDecimal.class)) {
String bigDecimal = o.toString();
String bigDecimal = ((BigDecimal) o).toPlainString();
String replace = bigDecimal.replace(".", "");
if (replace.length() > max) {
return "参数校验错误[" + f.getName() + ":" + message + "]";
......@@ -49,11 +49,13 @@ public class ValidatorUtil {
if (f.isAnnotationPresent(DecimalLength.class)) {
DecimalLength annotation = f.getAnnotation(DecimalLength.class);
int i = bigDecimal.indexOf(".");
if (i > -1) {
String substring = bigDecimal.substring(i + 1);
if (substring.length() > annotation.value()) {
return "参数校验错误[" + f.getName() + ":小数点最大" + annotation.value() + "]";
}
}
}
}
}
......
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