package thyyxxk.webserver.constants.sidicts;

import lombok.Getter;
import thyyxxk.webserver.utils.StringUtil;

/**
 * @description: 人员证件类型
 * @author: DingJie
 * @create: 2021/7/1010:02
 */
@Getter
public enum PsnCertType {

    RESIDENT_IDENTITY_CARD("01", "居民身份证（户口簿）"),

    PLA_OFFICER_CERTIFICATE("02", "中国人民解放军军官证"),

    ARMED_POLICE_OFFICER_CERTIFICATE("03", "中国人民武装警察警官证"),

    HK_SAR_PASSPORT("04", "香港特区护照/港澳居民来往内地通行证"),

    MACAO_SAR_PASSPORT("05", "澳门特区护照/港澳居民来往内地通行证"),

    TAIWAN_RESIDENT_PASS("06", "台湾居民来往大陆通行证"),

    PERMANENT_RESIDENCE_PERMIT_FOR_FOREIGNERS("07", "外国人永久居留证"),

    FOREIGN_PASSPORT("08", "外国人护照"),

    DISABILITY_CERTIFICATE("09", "残疾人证"),

    PROOF_OF_MILITARY_MARTYRS_FAMILY("10", "军烈属证明"),

    ALIEN_EMPLOYMENT_PERMIT("11", "外国人就业证"),

    FOREIGN_EXPERT_CERTIFICATE("12", "外国专家证"),

    FOREIGN_RESIDENT_PRESS_CARD("13", "外国人常驻记者证"),

    EMPLOYMENT_CERTIFICATE_FOR_THM("14", "台港澳人员就业证"),

    EXPERT_CERTIFICATE_FOR_HOME_SETTLEMENT("15", "回国（来华）定居专家证"),

    CHINESE_PASSPORT("16", "中国护照"),

    RESIDENCE_PERMIT_FOR_HMT("17", "港澳台居民居住证"),

    SOCIAL_SECURITY_CARD("90", "社会保障卡"),

    POVERTY_CODE("990102", "扶贫人口编码"),

    MEDICAL_BIRTH_CERT("990201", "医学出生证明"),

    OTHER_IDENTITY_DOCUMENTS("99", "其他身份证件");

    private final String code;
    private final String name;

    PsnCertType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static PsnCertType get(String code) {
        if (StringUtil.isBlank(code)) {
            return OTHER_IDENTITY_DOCUMENTS;
        }
        for (PsnCertType psnCertType : PsnCertType.values()) {
            if (code.trim().equals(psnCertType.getCode())) {
                return psnCertType;
            }
        }
        return OTHER_IDENTITY_DOCUMENTS;
    }
}
