package com.ruoyi.info.service.exception;

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


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

    // TODO 注意检查错误码，保证系统内唯一
    ServiceProduct_IS_NOT_EXISTS(160001, "服务不存在"),
    ServiceProduct_NAME_EXISTS(160002, "服务名称已经存在"),
    ServiceProduct_EXISTS_ON_SALE(160003, "服务状态为已上架，不可删除");

    private Integer code;

    private String msg;

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

}
