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
|
) {
|
|
public static DependentCardApplyItemResponse from(DependentCardApply apply) {
|
return new DependentCardApplyItemResponse(
|
apply.getId(),
|
apply.getDependentName(),
|
maskMobile(apply.getDependentMobile()),
|
apply.getStatus(),
|
statusText(apply.getStatus()),
|
apply.getRelation()
|
);
|
}
|
|
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 -> "未知";
|
};
|
}
|
}
|