package com.ycwl.basic.enums;

import lombok.Getter;

/**
 * <p>@AUTHOR: songmingsong</p>
 */
@Getter
public enum WechatErrorCodeEnum {
    /**
     * 无效的预登陆code
     */
    INVALID_CODE("40029", "无效的预登陆code"),

    /**
     * 预登陆code已经使用
     */
    CODE_IS_USED("40163", "预登陆code已经使用"),

    /**
     * 无效的AppSecret
     */
    INVALID_APP_SECRET("40125", "无效的AppSecret"),

    /**
     * 未知的微信错误
     */
    UNKNOWN_ERROR_CODE("50000", "未知的微信错误");

    WechatErrorCodeEnum(String code, String detail) {
        this.code = code;
        this.detail = detail;
    }

    private String code;

    private String detail;

    public static WechatErrorCodeEnum getErrorCode(String code) {
        for (WechatErrorCodeEnum wechatErrorCodeEnum : WechatErrorCodeEnum.values()) {
            if (wechatErrorCodeEnum.code.equals(code)) {
                return wechatErrorCodeEnum;
            }
        }
        return UNKNOWN_ERROR_CODE;
    }
}
