package com.ruoyi.info.order.exception;

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


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

    // TODO 注意检查错误码，保证系统内唯一
    Order_IS_NOT_EXISTS(800001, "订单不存在"),
    Order_IS_NOT_YOURS(800002, "当前订单不是您本人的订单，不可取消！"),
    Order_STATUS_ERROR(800003, "订单不是待确认，不可取消！"),
    Order_WORKER_NOT_IN_HOSPITAL(800004, "当前护工的常驻医院不在本医院，不可分配！"),
    Order_WORKER_NOT_ENABLE(800005, "当前护工状态不可接单，不可分配！"),
    Order_STATUS_IS_NOT_ASSIGN(800006, "当前订单状态无法分配或更换护工！"),
    Order_STATUS_IS_NOT_START(800007, "当前订单状态无法开始服务！"),
    Order_WORKER_IS_NOT_YOURS(800008, "当前订单的护工不是您本人，无法操作！"),
    Order_STATUS_IS_NOT_PROGRESS(800009, "当前订单状态无法完成服务！"),
    Order_STATUS_IS_NOT_EVALUATED(800010, "当前订单状态无法评价！");

    private Integer code;

    private String msg;

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

}
