package com.ruoyi.info.quicklink.exception;

import com.ruoyi.common.enums.IIntegerEnum;

import java.util.Objects;


/**
 * 异常枚举
 */
public enum QuiclLinkExceptionEnum implements IIntegerEnum {

    // TODO 注意检查错误码，保证系统内唯一
    THEMEMODULE_IS_NOT_EXISTS(5000001, "聚合主题模块不存在"),
    THEMEMODULE_IS_NAME_REPEAT(5000002, "聚合主题模块名称已存在"),

    OUTER_ADDRESS_EMPTY(500001, "外部链接不能为空"),
    INNER_PAGE_CODE_EMPTY(500002, "内部页面标识不能为空"),
    RESOURCE_MODEL_EMPTY(500003, "内部资源标识不能为空"),
    RESOURCE_MODEL_ID_EMPTY(500004, "内部资源标识不能为空"),
    RESOURCE_MODEL_TITLE_EMPTY(500005, "内部资源标题不能为空"),

    ;

    private Integer code;

    private String msg;

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

    @Override
    public Integer getCode() {
        return code;
    }

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

    @Override
    public String getMsg() {
        return msg;
    }

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

    public static QuiclLinkExceptionEnum getByCode(int code, QuiclLinkExceptionEnum[] values) {
        for (QuiclLinkExceptionEnum value : values) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }

}
