package com.ruoyi.common.enums;

import java.util.Objects;

/**
 * @author 异常
 */
public enum ExceptionEnum implements IIntegerEnum{
    USER_NOT_LOGIN(100001, "用户未登录"),
    USER_NOT_EXISTS(100002, "用户不存在"),
    USER_DISABLED(100003, "用户被禁用"),
    TOKEN_EXPIRED(100004, "用户登录已过期"),
    TOKEN_ERROR(100005, "用户校验未通过"),
    EMPTY_JSCODE(100006, "OpenId不能为空"),
    USER_EXCEPTION(100007, "用户不存在"),
    MOBILE_HAS_BEEN_BOUND_TO_ACCOUNT(100008, "该手机已绑定其他账户，请输入正确的账号"),

    ;

    private Integer code;
    private String msg;

    ExceptionEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    public static ExceptionEnum getByCode(int code, ExceptionEnum[] values) {
        for (ExceptionEnum value : values) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
