首页>代码>springboot集成rabbitmq生产者消费者模型>/springboot-rabbitmq/src/main/java/com/simon/springbootrabbitmq/ApiErrorCode.java
package com.simon.springbootrabbitmq;

/**
 * @author Simon
 */

public enum ApiErrorCode {

    /**
     * 失败
     */
    FAILED(-1, "操作失败"),

    /**
     * 服务 异常
     */
    SERVICE(500, "服务异常"),

    /**
     * 成功
     */
    SUCCESS(0, "执行成功");

    private final long code;
    private final String msg;

    ApiErrorCode(final long code, final String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ApiErrorCode fromCode(long code) {
        ApiErrorCode[] ecs = ApiErrorCode.values();
        for (ApiErrorCode ec : ecs) {
            if (ec.getCode() == code) {
                return ec;
            }
        }
        return SUCCESS;
    }

    public long getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    @Override
    public String toString() {
        return String.format(" ErrorCode:{code=%s, msg=%s} ", code, msg);
    }
}
最近下载更多
最代码官方  LV167 2023年2月26日
最近浏览更多
笛卡尔积  LV6 2023年9月25日
duon12  LV1 2023年9月25日
gaoxin222  LV14 2023年6月16日
1529860026  LV24 2023年6月1日
3054069007  LV1 2023年5月29日
陆程江  LV2 2023年5月29日
北。  LV6 2023年4月28日
master_guo  LV7 2023年4月12日
做你的景天  LV7 2023年3月30日
走你個魯  LV21 2023年3月27日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友