package com.ruoyi.info.collection.enums;


/**
 * 性别枚举
 *
 * @author ruoyi
 */
public enum Gender {

    /** 男 */
    MALE("M", "男"),

    /** 女 */
    FEMALE("F", "女"),

    /** 其他 */
    OTHER("O", "其他");

    private final String code;
    private final String desc;

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

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据编码获取描述
     */
    public static String getDescByCode(String code) {
        for (Gender gender : values()) {
            if (gender.getCode().equals(code)) {
                return gender.getDesc();
            }
        }
        return null;
    }
}
