package com.fs.common.enums;

/**
 * 用户类型枚举
 * 0-销售用户
 * 1-系统用户
 */
public enum UserTypeEnum {

    SALES(0, "销售用户"),
    SYSTEM(1, "系统用户");

    private final Integer code;
    private final String desc;

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

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据 code 获取枚举
     */
    public static UserTypeEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (UserTypeEnum e : values()) {
            if (e.code.equals(code)) {
                return e;
            }
        }
        return null;
    }
}
