package com.jeequan.jeepay.core.model.openapi;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public class AccessError {

    private String code;

    private String msg;

    public static final String CODE_SUCCESS = "000000";

    public static final AccessError SUCCESS = new AccessError(CODE_SUCCESS, "请求成功");


    // 定义通用code
    /**
     * 参数非法，主要用于限定范围的参数
     */
    public static final String CODE_ILLEGAL_PARAM_ERROR = "100001";

    /**
     * 无权限
     */
    public static final String FORBIDDEN = "100005";

    /**
     * 通用状态不正确
     */
    public static final String CODE_DATA_STATE_ERROR = "200012";

    /**
     * 签名校验失败
     */
    public static final String CODE_SIGN_CHECK_ERROR = "300001";

    /**
     * 配置异常类错误
     */
    public static final String CODE_CONFIG_ERROR = "300005";

    /**
     * 数据异常错误
     */
    public static final String CODE_DATA_GET_ERROR = "400001";

    /**
     * 通用错误码，用于一些未定义的错误类型
     */
    public static final String CODE_COMMON_ERROR = "900000";

    public static final AccessError COMMON_DATA_ERROR = new AccessError(CODE_DATA_GET_ERROR, "数据获取失败");

    public static final AccessError COMMON_ERROR = new AccessError(CODE_COMMON_ERROR, "系统异常，详情请咨询客服");

    public static final AccessError SIGN_CHECK_ERROR = new AccessError(CODE_SIGN_CHECK_ERROR, "签名校验失败");

    public static AccessError stateError(String message) {
        return new AccessError(CODE_DATA_STATE_ERROR, message);
    }

    public static AccessError dataError(String message) {
        return new AccessError(CODE_DATA_GET_ERROR, message);
    }

    public static AccessError commonError(String message) {
        return new AccessError(CODE_COMMON_ERROR, message);
    }

    public static AccessError configError(String message) {
        return new AccessError(CODE_CONFIG_ERROR, message);
    }
}
