package com.cf.imes.framework.common.exception.enums;

import com.cf.imes.framework.common.exception.ErrorCode;

/**
 * 全局错误码枚举
 * 0-999 系统异常编码保留
 *
 * 一般情况下，使用 HTTP 响应状态码 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status
 * 虽然说，HTTP 响应状态码作为业务使用表达能力偏弱，但是使用在系统层面还是非常不错的
 * 比较特殊的是，因为之前一直使用 0 作为成功，就不使用 200 啦。
 *
 * @author 晨丰科技
 */
public class GlobalErrorCodeConstants {

    public static final ErrorCode SUCCESS = new ErrorCode(0, "成功");

    // ========== 客户端错误段 ==========

    public static final ErrorCode BAD_REQUEST = new ErrorCode(400, "global.error.bad.request");
    public static final ErrorCode UPLOAD_SIZE_EXCEEDED = new ErrorCode(413, "global.error.request.upload.size.exceed");
    public static final ErrorCode REQUEST_ORGAN_ID_NOT_EXIST = new ErrorCode(400, "global.error.request.organId.notExist");
    public static final ErrorCode NO_PERMISSION_TO_VISIT_ORG = new ErrorCode(400, "global.error.no.permission.to.visit.org");
    public static final ErrorCode REQUEST_PARAM_TYPE_ERROR = new ErrorCode(400, "global.error.request.param.type.error");
    public static final ErrorCode UNAUTHORIZED = new ErrorCode(401, "global.not.login");
    public static final ErrorCode BE_KICKED_OUT = new ErrorCode(401, "be.kicked.out");
    public static final ErrorCode FORBIDDEN = new ErrorCode(403, "global.error.no.permission");
    public static final ErrorCode REQUEST_PARAM_MISSING = new ErrorCode(403, "global.error.request.param.missing");
    public static final ErrorCode NOT_FOUND = new ErrorCode(404, "global.error.request.not.found");
    public static final ErrorCode METHOD_NOT_ALLOWED = new ErrorCode(405, "global.error.request.method.error");
    public static final ErrorCode TOO_MANY_REQUESTS = new ErrorCode(429, "global.error.request.too.many");
    public static final ErrorCode ORG_PRODUCT_EXPIRED = new ErrorCode(410, "global.org.product.expired");
    public static final ErrorCode USER_PRODUCTID_NOT_EXIST = new ErrorCode(410, "global.org.product.not.exist");

    // ========== 服务端错误段 ==========

    public static final ErrorCode INTERNAL_SERVER_ERROR = new ErrorCode(500, "global.error.default.error");
    public static final ErrorCode DUPLICATE_DATA_ERROR = new ErrorCode(500, "global.error.request.duplicate.data.error");
    public static final ErrorCode NOT_IMPLEMENTED = new ErrorCode(501, "功能未实现/未开启");

    // ES文档更新失败
    // ES文档删除失败
    // ES文档刷新失败
    public static final ErrorCode ES_DATA_ERROR = new ErrorCode(503, "数据异常，请勿点击过快，请稍等再试");
    public static final ErrorCode DATA_EXCEPTION_ERROR = new ErrorCode(505, "数据异常，请联系客服处理");
    public static final ErrorCode DATA_DATA_ERROR = new ErrorCode(506, "文档数据异常，请勿频繁操作，请稍后重试");

    // ========== 自定义错误段 ==========
    public static final ErrorCode DEMO_DENY = new ErrorCode(901, "演示模式，禁止写操作");
}
