package org.jeecg.common.aspect.baiduAddress;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;

@Slf4j
public enum BaiDuError {




    // 成功状态
    SUCCESS(0,"请求处理成功"),

    // 错误状态（根据表格内容实现）
    INTERNAL_ERROR(1,"服务器内部错误"),

    INVALID_PARAM(2,"请求参数非法"),

    AUTH_FAILURE(3,"权限校验失败"),

    QUOTA_EXCEEDED(4,"配额校验失败"),

    INVALID_AK(5,"AK不存在或者非法"),

    MISSING_AK(101,"AK参数不存在"),

    IP_BLOCKED(102,"不通过白名单或者安全码不对"),

    SERVICE_DISABLED(240,"APP服务被禁用");


    private int code;
    private String value;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    BaiDuError(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public static BaiDuError getByType(int code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (BaiDuError val : values()) {
            if (val.getCode() == code) {
                return val;
            }
        }
        return null;
    }
}
