|
@@ -18,6 +18,7 @@ import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -109,6 +110,9 @@ public class FamilyJoinRequestService {
|
|
|
throw new RuntimeException("用户不存在");
|
|
throw new RuntimeException("用户不存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 准入校验:被邀请人必须已完善真实姓名/出生日期/性别(需求变更 2026-11-07-family-join-required-info)
|
|
|
|
|
+ validateJoinRequiredInfo(currentUser);
|
|
|
|
|
+
|
|
|
// 检查用户是否已属于该家庭
|
|
// 检查用户是否已属于该家庭
|
|
|
if (currentUser.getFamilyId() != null && currentUser.getFamilyId().equals(family.getId())) {
|
|
if (currentUser.getFamilyId() != null && currentUser.getFamilyId().equals(family.getId())) {
|
|
|
throw new RuntimeException("您已是该家庭成员");
|
|
throw new RuntimeException("您已是该家庭成员");
|
|
@@ -144,6 +148,35 @@ public class FamilyJoinRequestService {
|
|
|
return request;
|
|
return request;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 准入校验:被邀请人申请加入家庭前必须已完善真实姓名、出生日期、性别(规格 2026-11-07-family-join-required-info)
|
|
|
|
|
+ * - 真实姓名:trim 后非空,长度 1–20 字;
|
|
|
|
|
+ * - 出生日期:非空、不晚于今天、不早于 1900-01-01(年龄不设上限);
|
|
|
|
|
+ * - 性别:仅限 male / female 二值(大小写敏感)。
|
|
|
|
|
+ */
|
|
|
|
|
+ private void validateJoinRequiredInfo(User u) {
|
|
|
|
|
+ final String genMsg = "请先完善真实姓名、出生日期与性别后再申请加入家庭";
|
|
|
|
|
+ String realName = u.getRealName();
|
|
|
|
|
+ if (realName == null || realName.trim().isEmpty() || realName.trim().length() > 20) {
|
|
|
|
|
+ throw new RuntimeException(genMsg);
|
|
|
|
|
+ }
|
|
|
|
|
+ Date birthday = u.getBirthday();
|
|
|
|
|
+ if (birthday == null) {
|
|
|
|
|
+ throw new RuntimeException(genMsg);
|
|
|
|
|
+ }
|
|
|
|
|
+ String gender = u.getGender();
|
|
|
|
|
+ if (!"male".equals(gender) && !"female".equals(gender)) {
|
|
|
|
|
+ throw new RuntimeException(genMsg);
|
|
|
|
|
+ }
|
|
|
|
|
+ java.sql.Date today = java.sql.Date.valueOf(LocalDate.now());
|
|
|
|
|
+ if (birthday.after(today)) {
|
|
|
|
|
+ throw new RuntimeException("出生日期不能晚于今天");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (birthday.before(java.sql.Date.valueOf(LocalDate.of(1900, 1, 1)))) {
|
|
|
|
|
+ throw new RuntimeException("出生日期不合法");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 审批通过加入请求(兼容旧调用:不指定辈分 → 仅写 familyRole,不落地辈分/关系)
|
|
* 审批通过加入请求(兼容旧调用:不指定辈分 → 仅写 familyRole,不落地辈分/关系)
|
|
|
*/
|
|
*/
|