package com.backendsys.modules.common.utils;

/**
 * 定义API返回码枚举类
 */
public enum ResultEnum {

    /* 成功状态码 */
    SUCCESS(200, "成功"),

    /* 错误状态码 */
    NOT_FOUND(404, "请求的资源不存在"),
    AUTH_ERROR(401, "授权失败!"),
    AUTH_ROLE_ERROR(403, "该用户角色没有访问权限"),
    AUTH_USER_ERROR(403, "该用户不可操作"),
    /**
     * 用户权限枚举
     */

    TOKEN_EMPTY_ERROR(401, "请先登录获取有效的Token"),
    INVALID_CREDENTIALS(402, "用户名或密码错误"),
    LOCK_CREDENTIALS(4024, "错误次数过多，为账号安全，请等待1分钟后重新尝试"),

    CAPTCHA_ERROR(403, "验证码错误"),
    UNIQUE_FIELD(409, "唯一字段已存在"),

    HTTP_BODY_EMPTY(420, "请求体参数不能为空"),
    HTTP_METHOD_ERROR(421, "请求方法不支持"),

    TOKEN_EXPIRED(440, "Token已过期，请重新登录"),
    TOKEN_INVALID(441, "Token已失效，请重新登录"),
    TOKEN_FORMAT_EXCEPTION(442, "Token格式异常"),
    TOKEN_FORMAT_INCORRECT(443, "Token格式不正确"),


    STATUS_ERROR(499, "资源状态暂不可用"),
    INTERNAL_ERROR(500, "服务器内部错误"),
    PARAMETER_EXCEPTION(6001, "参数校验异常"),
    REMOTE_EXCEPTION(6002, "远程资源异常"),
    NULL_POINTER(7001, "空指针异常"),
    REFLECTION_EXCEPTION(8001, "Mybatis反射操作异常"),
    SERVICE_EXCEPTION(502, "远程服务器错误"),
    SERVER_BUSY(503, "服务器正忙，请稍后再试!"),
    DATABASE_OPERATION_FAILED(504, "数据库操作失败"),
    REDIS_ERROR(601, "Redis Error");

    private int code;
    private String message;


    public int getCode() {
        return this.code;
    }
    public String getMessage() {
        return this.message;
    }

    ResultEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }
}
