shinnosuke
2026-08-20 40dd0e9898bf2a88e51d497c46d826ea8f7326f4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.talentcard.server.response;
 
import com.talentcard.server.entity.DependentCardApply;
import io.swagger.v3.oas.annotations.media.Schema;
 
@Schema(name = "DependentCardApplyItemResponse", description = "小程序家属附属卡申请信息")
public record DependentCardApplyItemResponse(
        @Schema(description = "数据ID", example = "1001")
        Long id,
        @Schema(description = "家属姓名", example = "张三")
        String dependentName,
        @Schema(description = "脱敏手机号", example = "138****8000")
        String dependentMobile,
        @Schema(description = "审核状态:0待审核、1已通过、2已驳回、3已解绑", example = "1")
        Integer status,
        @Schema(description = "审核状态文本", example = "已通过")
        String statusText,
        @Schema(description = "家属关系", example = "配偶")
        String relation,
        @Schema(description = "驳回原因;仅已驳回时返回", example = "身份证照片不清晰")
        String auditRemark
) {
 
    public static DependentCardApplyItemResponse from(DependentCardApply apply) {
        return new DependentCardApplyItemResponse(
                apply.getId(),
                apply.getDependentName(),
                maskMobile(apply.getDependentMobile()),
                apply.getStatus(),
                statusText(apply.getStatus()),
                apply.getRelation(),
                apply.getAuditRemark()
        );
    }
 
    private static String maskMobile(String mobile) {
        if (mobile == null || mobile.length() < 7) {
            return "";
        }
        return mobile.substring(0, 3) + "****" + mobile.substring(7);
    }
 
    private static String statusText(Integer status) {
        if (status == null) {
            return "";
        }
        return switch (status) {
            case DependentCardApply.STATUS_PENDING_REVIEW -> "待审核";
            case DependentCardApply.STATUS_APPROVED -> "已通过";
            case DependentCardApply.STATUS_REJECTED -> "已驳回";
            case DependentCardApply.STATUS_CANCELLED -> "已解绑";
            default -> "未知";
        };
    }
}