package com.fdkankan.common.constant;

/**
 * 操作类型枚举
 */
public enum OperationType {

    DELETE(-1, "删除"),
    UPDATE(0, "修改"),
    ADD(1, "新增"),
    ADDORUPDATE(2, "新增或修改");

    private Integer code;
    private String message;

    private OperationType(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer code() {
        return code;
    }

    public String message() {
        return message;
    }

    public static OperationType get(Integer code){
        OperationType[] values = OperationType.values();
        Integer enumValue = null;
        for(OperationType eachValue : values){
            enumValue = eachValue.code();
            if(enumValue.equals(code)){
                return eachValue;
            }
        }
        return null;
    }

}
