package com.ruoyi.info.service.exception;

import com.ruoyi.common.enums.IIntegerEnum;
import java.util.Objects;


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

    // TODO 注意检查错误码，保证系统内唯一
    ServiceCategorize_IS_NOT_EXISTS(150001, "服务分类不存在"),
    ServiceCategorize_NAME_EXISTS(150002, "服务分类名称已经存在"),
    ServiceCategorize_EXISTS_ON_SALE(150003, "服务分类状态为已上架，不可删除"),
    ServiceCategorize_EXISTS_ON_PRODUCT(150004, "服务分类已被服务引用，不可删除"),
    ;

    private Integer code;

    private String msg;

    ServiceCategorizeExceptionEnum(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 ServiceCategorizeExceptionEnum getByCode(int code, ServiceCategorizeExceptionEnum[] values) {
        for (ServiceCategorizeExceptionEnum value : values) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }

}
