Просмотр исходного кода

fix(cfc-backend): add GenerationLevel enum and family member entity updates

Ultraworked with Sisyphus

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
User 3 месяцев назад
Родитель
Сommit
538224b142

+ 12 - 3
cfc-backend/src/main/java/com/etotem/cfc/dto/AddFamilyMemberDTO.java

@@ -2,9 +2,21 @@ package com.etotem.cfc.dto;
 
 import lombok.Data;
 
+/**
+ * 添加家庭成员请求DTO
+ */
 @Data
 public class AddFamilyMemberDTO {
 
+    /** 关联成员ID(辈分参照点,必填) */
+    private Long relativeMemberId;
+
+    /** 辈分等级(必填):great_grandparent/grandparent/parent/peer/child/grandchild/great_grandchild */
+    private String generationLevel;
+
+    /** 同辈类型(仅 generationLevel=peer 时填写):sibling=亲兄弟姐妹,spouse=配偶 */
+    private String peerType;
+
     /** 昵称(必填) */
     private String nickname;
 
@@ -20,9 +32,6 @@ public class AddFamilyMemberDTO {
     /** 出生日期 yyyy-MM-dd */
     private String birthday;
 
-    /** 关系类型key(必填) */
-    private String relationshipType;
-
     /** 角色覆盖: auto/parent/child/elderly(选填,默认auto) */
     private String roleOverride;
 }

+ 3 - 0
cfc-backend/src/main/java/com/etotem/cfc/dto/FamilyMemberVO.java

@@ -46,6 +46,9 @@ public class FamilyMemberVO {
     /** 视角相关的关系标签(如 "我"/"儿子"/"女儿"/"父亲"/"母亲"/"哥哥"/"姐姐") */
     private String relativeLabel;
 
+    /** 辈分级(0=家庭创建者,+n=向上,-n=向下) */
+    private Integer generation;
+
     /** 年龄 */
     private Integer age;
 

+ 20 - 0
cfc-backend/src/main/java/com/etotem/cfc/entity/FamilyMember.java

@@ -44,6 +44,12 @@ public class FamilyMember implements Serializable {
     /** 角色覆盖: auto/parent/child/elderly,空=auto */
     private String roleOverride;
 
+    /** 辈分值(0=家庭创建者,+n=向上n代,-n=向下n代) */
+    private Integer generation;
+
+    /** 是否配偶(同辈中) */
+    private Boolean isSpouse;
+
     /** 对家庭成员可见: 1=可见, 0=不可见 */
     private Integer showToFamily;
 
@@ -98,6 +104,20 @@ public class FamilyMember implements Serializable {
 
     private Date updatedAt;
 
+    /**
+     * 是否男性
+     */
+    public boolean isMale() {
+        return "male".equals(gender);
+    }
+
+    /**
+     * 是否女性
+     */
+    public boolean isFemale() {
+        return "female".equals(gender);
+    }
+
     /**
      * 计算年龄(根据birthday)
      */

+ 46 - 0
cfc-backend/src/main/java/com/etotem/cfc/enums/GenerationLevel.java

@@ -0,0 +1,46 @@
+package com.etotem.cfc.enums;
+
+/**
+ * 辈分等级枚举
+ * 家庭创建者 generation = 0
+ * +n = 向上一 n 代(父母辈=+1,祖辈=+2,曾祖辈=+3)
+ * -n = 向下一 n 代(子侄辈=-1,孙辈=-2,曾孙辈=-3)
+ */
+public enum GenerationLevel {
+
+    GREAT_GRANDPARENT("great_grandparent", 3),
+    GRANDPARENT("grandparent", 2),
+    PARENT("parent", 1),
+    PEER("peer", 0),
+    CHILD("child", -1),
+    GRANDCHILD("grandchild", -2),
+    GREAT_GRANDCHILD("great_grandchild", -3);
+
+    private final String value;
+    private final int offset;
+
+    GenerationLevel(String value, int offset) {
+        this.value = value;
+        this.offset = offset;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public static GenerationLevel fromValue(String value) {
+        if (value == null || value.isEmpty()) {
+            return null;
+        }
+        for (GenerationLevel gl : values()) {
+            if (gl.value.equals(value)) {
+                return gl;
+            }
+        }
+        return null;
+    }
+}

+ 1 - 1
cfc-backend/src/main/resources/application.yml

@@ -75,7 +75,7 @@ wechat:
   notify-url: http://cfc.bianwoyou.com.cn/api/payment/notify
   login-url: https://api.weixin.qq.com/sns/jscode2session
   phone-url: https://api.weixin.qq.com/wxa/business/getuserphonenumber
-  test-mode: true  # 测试模式:跳过微信API调用,使用模拟数据
+  test-mode: false  # 测试模式:跳过微信API调用,使用模拟数据
   test-phone: "13800138000"  # 测试模式使用的手机号
   alert-template-id: ${WECHAT_ALERT_TEMPLATE_ID:}