package com.ruoyi.common.importExcel.excel;

import com.ruoyi.common.exception.ServiceErrorException;

/**
 * 费用类型
 *
 * @author CAC
 * @date 2020-04-01 12:00:00
 */
public enum OperationEnum {

    /**
     * 新增
     */
    INSERT(1, "增"),
    /**
     * 修改
     */
    UPDATE(2, "改"),
    /**
     * 删除
     */
    DELETE(3, "删");

    private final Integer value;

    private final String name;

    OperationEnum(final Integer value, final String name) {
        this.value = value;
        this.name = name;
    }

    public Integer getValue() {
        return this.value;
    }

    public String getName() {
        return this.name;
    }

    public static OperationEnum getEnum(Integer value) {
        for (OperationEnum logicEnum : OperationEnum.values()) {
            if (logicEnum.getValue().equals(value)) {
                return logicEnum;
            }
        }
        throw new ServiceErrorException("Invalid ExpenseTypeEnum type value: " + value);
    }

    public static Integer valueOfName(String name) {
        for (OperationEnum logicEnum : OperationEnum.values()) {
            if (logicEnum.getName().equals(name)) {
                return logicEnum.getValue();
            }
        }
        return null;
    }
}
