Commit 99f7e07c by zhangxingmin

push

parent 760e13be
......@@ -81,17 +81,17 @@ public class ApiInsurantInfoDto {
@NotNull(message = "受保人-生日不能为空", groups = GroupValid.NotSelf.class)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime birthday;
@AssertTrue(message = "受保人-必须大于18周岁", groups = GroupValid.NotSelf.class)
public boolean isBirthdayValid() {
if (birthday == null) {
// @NotNull 会处理空值
return true;
}
LocalDateTime now = LocalDateTime.now();
// 计算年龄
int age = Period.between(birthday.toLocalDate(), now.toLocalDate()).getYears();
return age > 18;
}
// @AssertTrue(message = "受保人-必须大于18周岁", groups = GroupValid.NotSelf.class)
// public boolean isBirthdayValid() {
// if (birthday == null) {
// // @NotNull 会处理空值
// return true;
// }
// LocalDateTime now = LocalDateTime.now();
// // 计算年龄
// int age = Period.between(birthday.toLocalDate(), now.toLocalDate()).getYears();
// return age > 18;
// }
/**
* 年龄(通过生日自动获取年龄)
......
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