package com.backendsys.utils.response;

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

    SUCCESS(200, "成功", "result.success"),
    NOT_FOUND(404, "请求的资源不存在", "result.not.found"),
    AUTH_ERROR(401, "授权失败!", "result.auth.error"),
    AUTH_ROLE_ERROR(403, "该用户角色没有访问权限", "result.auth.role.error"),
    AUTH_USER_ERROR(403, "该用户不可操作", "result.auth.user.error"),
    TOKEN_EMPTY_ERROR(401, "请先登录获取有效的Token", "result.token.empty.error"),
    INVALID_CREDENTIALS(402, "用户名或密码错误", "result.invalid.credentials"),
    LOCK_CREDENTIALS(4024, "错误次数过多，为账号安全，请等待1分钟后重新尝试", "result.lock.credentials"),
    CAPTCHA_ERROR(403, "验证码错误", "result.captcha.error"),
    UNIQUE_FIELD(409, "唯一字段已存在", "result.unique.field"),
    HTTP_BODY_EMPTY(420, "请求体参数不能为空", "result.http.body.empty"),
    HTTP_METHOD_ERROR(421, "请求方法不支持", "result.http.method.error"),
    TOKEN_EXPIRED(440, "Token已过期，请重新登录", "result.token.expired"),
    TOKEN_INVALID(441, "Token已失效，请重新登录", "result.token.invalid"),
    TOKEN_FORMAT_EXCEPTION(442, "Token格式异常", "result.token.format.exception"),
    TOKEN_FORMAT_INCORRECT(443, "Token格式不正确", "result.token.format.incorrect"),
    STATUS_CONFLICT(409, "资源冲突", "result.status.conflict"),
    STATUS_ERROR(499, "资源状态暂不可用", "result.status.error"),
    INTERNAL_ERROR(500, "服务器内部错误", "result.internal.error"),
    PARAMETER_EXCEPTION(6001, "参数校验异常", "result.parameter.exception"),
    REMOTE_EXCEPTION(6002, "远程资源异常", "result.remote.exception"),
    NULL_POINTER(7001, "空指针异常", "result.null.pointer"),
    REFLECTION_EXCEPTION(8001, "Mybatis反射操作异常", "result.reflection.exception"),
    SERVICE_EXCEPTION(502, "远程服务器错误", "result.service.exception"),
    SERVER_BUSY(503, "服务器正忙，请稍后再试!", "result.server.busy"),
    DATABASE_OPERATION_FAILED(504, "数据库操作失败", "result.database.operation.failed"),
    REDIS_ERROR(601, "Redis Error", "result.redis.error");

    private int code;
    private String message;
    private String message_key;


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

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