package com.qmth.sop.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
     */
    ATTACHMENT_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000001, "上传文件失败"),

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

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

    ATTACHMENT_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000004, "没有附件数据"),

    ORG_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000005, "没有机构数据"),

    USER_NO_EXISTS(HttpStatus.INTERNAL_SERVER_ERROR, 5000006, "没有用户数据"),

    ROLE_NO_EXISTS(HttpStatus.INTERNAL_SERVER_ERROR, 5000007, "没有角色数据"),

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

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

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

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

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

    FLOW_ENTITY_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000016, "流程没有实例数据"),

    FLOW_APPROVE_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000017, "流程没有审批数据"),

    FLOW_DEPLOYMENT_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000018, "流程没有部署数据"),

    FLOW_TASK_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000019, "流程任务数据为空"),

    FLOW_PROCESS_VAR_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000020, "流程过程变量数据为空"),

    CRM_NO_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000021, "派单号不能为空"),

    FLOW_CUSTOM_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000022, "流程部署数据为空"),

    FLOW_APPROVE_LOG_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000023, "流程没有审批日志数据"),

    DING_APPLY_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000024, "没有考勤异常申请数据"),

    DING_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000025, "没有考勤数据"),

    PROJECT_EXCHANGE_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000026, "没有项目计划变更申请数据"),

    SOP_INFO_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000027, "没有sop数据"),

    QUALITY_PROBLEM_APPLY_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000028, "没有质量问题反馈申请数据"),

    FLOW_DATA_NOT_ME(HttpStatus.INTERNAL_SERVER_ERROR, 5000029, "不能审批他人的流程数据"),

    FLOW_TASK_ID_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 5000030, "流程节点id不能为空"),

    FLOW_FORM_PROPERTIES_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 5000031, "流程表单数据不能为空"),

    FLOW_REJECT_SETUP_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 5000032, "驳回步骤未填写"),

    SOP_DETAIL_INFO_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000033, "没有sop明细数据"),

    SERVICE_ID_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000034, "服务单元id不能为空"),

    WXAPP_OPENID_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000035, "微信用户未绑定"),

    WXAPP_PHONE_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000036, "微信手机号获取失败"),

    FLOW_SOP_DATA_NOT_ME(HttpStatus.INTERNAL_SERVER_ERROR, 5000037, "不能审批他人的sop数据"),

    SERVICE_DING_GROUP_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000038, "服务单元未设置考勤组"),

    SERVICE_DING_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000039, "服务单元未设置考勤对象角色"),

    SERVICE_DING_APPROVE_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000039, "服务单元未设置考勤审核角色"),

    SERVICE_DING_APPROVE_USER_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000040, "服务单元未找到审核角色用户"),

    FLOW_ALLOCATION_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000041, "流程审核角色数据未找到"),

    FLOW_ROLE_ALLOCATION_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000042, "流程未配置审核角色数据"),

    USER_ARCHIVES_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000043, "档案用户不存在"),

    WX_APP_LOGIN_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, 5000044, "对不起，您的角色无法登录移动端，请您通过PC端访问平台！"),

    SERVICE_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000045, "没有服务单元数据"),
    /**
     * 401
     */
    PLATFORM_INVALID(HttpStatus.UNAUTHORIZED, 4010001, "platform无效"),

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

    PRIVILEGE_ID_INVALID(HttpStatus.UNAUTHORIZED, 4010002, "privilegeId无效"),

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