package com.goafanti.ChatAI;

import java.util.HashMap;
import java.util.Map;

public enum BaiduChatErrorEnums {

    FWQCW(1,"服务器内部错误"),
    FWQBKY(2,"服务暂不可用"),
    APINOT(3,"调用的API不存在"),
    JQCCX(4,"集群超限额。"),
    WFWQX(6,"无权限访问该用户数据"),
    TKER(13,"获取token失败。"),
    IAMNOT(14,"IAM鉴权失败。"),
    APPNOT(15,"应用不存在或者创建失败。"),
    MAXER(17,"每天请求量超限额"),
    QPSER(18,"QPS超限额"),
    TKCXWX(19,"无效的access_token参数"),
    TKWX(100,"access_token验证无效"),
    TKGQ(110,"access token验证过期"),
    FWQNCW(111,"服务内部错误。"),
    RCER(336000,"入参格式有误"),
    BODYER(336002,"入参body不是标准的JSON格式。"),
    PRAMER(336003,"参数校验不合法"),
    RSGDER(336100,"互动的人过多，请您稍后重新向我提问。"),
    OTHER(0,"未知错误");


    private Integer code;
    private String msg;

    public Integer getCode() {
        return code;
    }

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

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    private BaiduChatErrorEnums(Integer code, String msg){
        this.code=code;
        this.msg=msg;
    }

    private static Map<String, BaiduChatErrorEnums> status = new HashMap<String, BaiduChatErrorEnums>();

    static {
        for (BaiduChatErrorEnums value : BaiduChatErrorEnums.values()) {
            status.put(value.getMsg(), value);
        }
    }

    public static BaiduChatErrorEnums getStatus(String code) {
        if (containsType(code)) {
            return status.get(code);
        }
        return OTHER;
    }
    public static boolean containsType(String code) {
        return status.containsKey(code);
    }

    public static String BycodeGetMsg(Integer code){
        for (BaiduChatErrorEnums value : status.values()) {
            if (code.equals(value.getCode())){
                return value.msg;
            }
        }
        return OTHER.msg;
    }

}
