package com.ruoyi.base.enums;

import com.ruoyi.common.enums.IIntegerEnum;

import java.util.Objects;

/**
 * 运费计算方式
 */
public enum FreightComputeMode implements IIntegerEnum<Integer> {
    ITEM(0, "按件"),
    WEIGHT(1, "按重量"),
    BULK(2, "按体积");

    private Integer code;

    private String msg;

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

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