package com.ruoyi.info.hospital.exception;

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


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

    // TODO 注意检查错误码，保证系统内唯一
    HOSPITAL_DEPARTMENT_IS_NOT_EXISTS(200001, "医院科室信息不存在"),

    HOSPITAL_DEPARTMENT_NAME_ALREADY_EXISTS(200002, "该医院下科室名称已经存在"),

    HOSPITAL_ID_CANNOT_CHANGE(200003, "科室的医院不可变更"),
    ;

    private Integer code;

    private String msg;

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

}
