package com.qmth.teachcloud.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
     */
    EXCEL_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000008, "excel没有数据"),

    USER_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000009, "用户或密码不正确"),

    PASSWORD_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000010, "密码不正确"),

    USER_ENABLE(HttpStatus.INTERNAL_SERVER_ERROR, 5000011, "用户已停用"),

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

    ROLE_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000013, "没有角色数据"),

    ATTACHMENT_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000014, "上传文件失败"),

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

    MD5_EQUALS_FALSE(HttpStatus.INTERNAL_SERVER_ERROR, 5000016, "md5不一致"),

    ATTACHMENT_TYPE_EMPTY(HttpStatus.INTERNAL_SERVER_ERROR, 5000017, "请上传文件类型"),

    TASK_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000018, "任务不存在"),

    PATH_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000019, "文件地址不存在"),

    SCHOOL_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000020, "学校信息不存在"),

    SCHOOL_ENABLE(HttpStatus.INTERNAL_SERVER_ERROR, 5000021, "学校已停用"),

    PAPER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 50000022, "当前没有未曝光的卷型"),

    PAPER_TYPE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 50000023, "未获取到试卷类型"),

    ATTACHMENT_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000024, "找不到附件"),

    EXAM_PRINT_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000025, "印刷计划为空"),

    EXAM_RULE_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000026, "考务规则为空"),

    EXAM_DETAIL_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000027, "考场数据为空"),

    EXAM_CARD_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000028, "题卡为空"),

    EXAM_TASK_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 50000029, "命题任务为空"),

    NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000030, "没有数据"),

    DATA_COUNT_EXCEPTION(HttpStatus.INTERNAL_SERVER_ERROR, 5000031, "得到的数据条数异常，应该有且仅有一条数据"),

    DATA_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000032, "数据异常"),

    SYNC_TASK_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000033, "同步任务不存在"),

    /**
     * 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);
    }
}