package com.qmth.teachcloud.exchange.common.enums;

import com.qmth.boot.api.exception.ApiException;
import org.springframework.http.HttpStatus;

/**
 * @Description: 自定义异常消息枚举
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2019/10/11
 */
public enum ExceptionResultEnum {
    /**
     * 系统预置
     */
    SUCCESS(HttpStatus.OK, 200, "成功"),

    ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000001, "失败"),

    PARAMS_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000002, "参数错误"),

    SQL_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000003, "sql异常:"),

    INVOCATIONTARGET_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000004, "反射异常:"),

    SERVICE_NOT_FOUND(HttpStatus.INTERNAL_SERVER_ERROR, 5000005, "服务器错误"),

    UNKONW_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000006, "未知错误:请联系管理员"),

    EXCEPTION_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000007, "系统异常:请联系管理员"),

    /**
     * 500
     */
    NOT_LOGIN(HttpStatus.INTERNAL_SERVER_ERROR, 5000012, "请先登录"),

    MD5_EMPTY(HttpStatus.INTERNAL_SERVER_ERROR, 5000015, "md5为空"),

    /**
     * 401
     */
    PLATFORM_INVALID(HttpStatus.UNAUTHORIZED, 4010001, "platform无效"),

    DEVICE_ID_INVALID(HttpStatus.UNAUTHORIZED, 4010002, "deviceId无效"),

    TOKEN_INVALID(HttpStatus.UNAUTHORIZED, 4010003, "token无效"),

    TIME_INVALID(HttpStatus.UNAUTHORIZED, 4010004, "time无效"),

    AUTHORIZATION_INVALID(HttpStatus.UNAUTHORIZED, 4010005, "authorization无效"),

    AUTHORIZATION_ERROR(HttpStatus.UNAUTHORIZED, 4010006, "签名验证失败"),

    UN_AUTHORIZATION(HttpStatus.UNAUTHORIZED, 4010007, "没有权限"),

    ROLE_ENABLE_AUTHORIZATION(HttpStatus.UNAUTHORIZED, 4010008, "角色被禁用或没有权限"),

    AUTH_INFO_ERROR(HttpStatus.UNAUTHORIZED, 4010009, "系统授权信息已过期，请联系系统管理员激活!"),

    SIGN_INVALID(HttpStatus.UNAUTHORIZED, 4010010, "签名无效"),

    /**
     * 404
     */
    NOT_FOUND(HttpStatus.NOT_FOUND, 4040003, "请求地址错误");

    private HttpStatus status;
    private int code;
    private String message;

    private ExceptionResultEnum(HttpStatus status, int code, String message) {
        this.status = status;
        this.code = code;
        this.message = message;
    }

    public HttpStatus getStatus() {
        return status;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public ApiException exception() {
        return new ApiException(status, code, message, message);
    }

    public ApiException exception(int code, String message) {
        return new ApiException(status, code, message, message);
    }

    public ApiException exception(String message) {
        return new ApiException(status, code, message, message);
    }
}