package cn.hanghui.outapi.platform.tenant.entity.enums;

import cn.hanghui.outapi.platform.common.utils.Preconditions;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @description 日志记录的操作类型
 */
@Getter
@AllArgsConstructor
public enum BusinessTypeEnum {

    INSERT(1, "新增"),
    UPDATE(2, "编辑"),
    DELETE(3, "删除"),
    INSERT_UPDATE(4, "新增/编辑"),
    AUTH(5, "授权"),
    CANCEL_AUTH(6, "取消授权"),
    AUTH_COMMON(7, "授权/取消授权"),
    OPEN(8, "启用"),
    CLOSE(9, "停用"),
    OTHER(99, "其他"),
    ;

    private Integer code;
    private String desc;


    public static BusinessTypeEnum getByCode(Integer code) {
        if(code == null){
            return OTHER;
        }
        for (BusinessTypeEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return OTHER;
    }

}
