package com.ruoyi.user.exception;

import com.ruoyi.common.enums.IIntegerEnum;

import java.util.Objects;


/**
 * 异常枚举
 */
public enum UserExceptionEnum implements IIntegerEnum {

    // TODO 注意检查错误码，保证系统内唯一
    USER_THIRD_ID_NOT_EXISTS(100011, "第三方用户不存在！"),
    MOBILE_USER_EXIST(100012, "手机号用户已存在！"),


    ;

    private Integer code;

    private String msg;

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

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

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

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

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

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

}
