package cn.reghao.oss.console.account.model.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 用户性别
 *
 * @author reghao
 * @date 2021-07-14 10:23:46
 */
public enum UserGender {
    female(0, "女"), male(1, "男"), unknown(2, "未知");

    private final Integer code;
    private final String desc;

    private static Map<Integer, String> descMap = new HashMap<>();
    static {
        for (UserGender gender : UserGender.values()) {
            descMap.put(gender.code, gender.desc);
        }
    }

    UserGender(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    // TODO 第一次调用时会初始化 descMap
    public static String getDescByCode(int code) {
        return descMap.get(code);
    }
}
