package com.bonus.sgzb.system.domain;

import lombok.Getter;

/**
 * 账号类型
 *
 * @author zhangshuwei
 * @create 2019-05-17 16:56
 **/
@Getter
public enum AccountTypeEnum {
    ALl(0,"全部"),
    PLATFORM(1,"运营方"),
    PURCHASE(2,"承租方"),
    SUPPLIER(3, "出租方"),
    RESUPPLIER(4,"转售商"),
    PERSONAL(5, "个人"),
    ENTERPRISE(6, "企业"),
    BUYER_SELLER(7, "承租方和出租方")
    ;

    private Integer code;
    private String desc;

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

    public static String getView(Integer code) {
        for (AccountTypeEnum enums : AccountTypeEnum.values()) {
            if (null != code && enums.code.equals(code)) {
                return enums.getDesc();
            }
        }
        return null;
    }

    /**
     * 根据枚举名 转换为枚举类
     *
     * @param code 枚举名
     * @return
     */
    public static AccountTypeEnum toEnum(Integer code) {
        for (AccountTypeEnum value : AccountTypeEnum.values()) {
            if (code.equals(value.getCode())) {
                return value;
            }
        }
        return null;
    }

}
