package thyyxxk.webserver.constants.sidicts;

import thyyxxk.webserver.utils.StringUtil;

/**
 * @description: 人员类别
 * @author: DingJie
 * @create: 2021/7/916:01
 */
public enum PsnType {

    ON_THE_JOB("11", "在职"),

    RETIRED("12", "退休"),

    EARLY_RETIRED("1204", "提前退休"),

    DISCHARGE("13", "离休"),

    NEW_BORN("1401", "新生儿"),

    PRESCHOOL_CHILDREN("1402", "学龄前儿童"),

    PRIMARY_AND_SECONDARY_SCHOOL_STUDENTS("1403", "中小学生"),

    COLLEGE_STUDENT("1404", "大学生"),

    MINOR_UNDERAGE("1405", "未成年（未入学）"),

    ADULT_RESIDENTS("15", "居民（成年）"),

    ELDERLY_RESIDENTS("16", "居民（老年）"),

    URBAN_AND_RURAL_RESIDENTS("1701", "城乡居民");

    private final String code;
    private final String name;

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

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static PsnType get(String code) {
        if (StringUtil.isBlank(code)) {
            return null;
        }
        for (PsnType psnType : PsnType.values()) {
            if (code.trim().equals(psnType.getCode())) {
                return psnType;
            }
        }
        return null;
    }
}
