package com.crm.rely.backend.core.constant;

/**
 * 卡证件类型
 * @author gao
 * @date 2025/11/4 16:29
 */
public enum CardIdTypeEnum {
    PASSPORT("PASSPORT", "护照"),
    HK_HKID("HK_HKID", "香港身份证"),
    DLN("DLN", "驾照"),
    GOVERNMENT_ISSUED_ID_CARD("GOVERNMENT_ISSUED_ID_CARD", "政府签发的身份证");

    private final String code;
    private final String description;

    CardIdTypeEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static CardIdTypeEnum fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (CardIdTypeEnum idType : values()) {
            if (idType.getCode().equals(code)) {
                return idType;
            }
        }
        return null;
    }

    public static String matchCode(String code) {
        CardIdTypeEnum idTypeEnum = fromCode(code);
        return idTypeEnum != null ? idTypeEnum.getDescription() : "";
    }
}
