package com.bonus.zlpt.equip.api.enums;

public enum MaStatusEnum {

    /** 待上架审批 */
    PENDING_APPROVAL(15, "待上架审批"),
    /** 待租 */
    ON_HIRE(16, "待租"),
    /** 在租 */
    UNDER_RENT(17, "在租"),
    /** 下架 */
    DELIST(18,"下架"),
    /** 自有 */
    SELF_OWNED(43,"自有");




    private final Integer code;
    private final String name;

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

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据code获取name
     * @param code
     * @return
     */
    public static String getNameByCode(int code) {
        MaStatusEnum[] maStatusEnums = values();
        for (MaStatusEnum maStatusEnum : maStatusEnums) {
            if (maStatusEnum.getCode() == code) {
                return maStatusEnum.getName();
            }
        }
        return null;
    }

    /**
     *
     * @param msg
     * @return
     */
    public static Integer getCodeByName(String msg) {
        MaStatusEnum[] maStatusEnums = values();
        for (MaStatusEnum maStatusEnum : maStatusEnums) {
            if (maStatusEnum.getName() == msg) {
                return maStatusEnum.getCode();
            }
        }
        return null;
    }


}
