package com.qmth.paper.library.common.enums.log;

import java.util.Objects;

/**
 * @Description: 被操作对象枚举类
 * @Author: CaoZixuan
 * @Date: 2022-02-14
 */
public enum OperationUnitEnum {
    UN_KNOW("未知", "", ""),
    TEACH_COURSE("操作'teach_course'表", "teach_course", "TeachCourse"),
    ;
    private final String desc;
    private final String table;
    private final String object;

    OperationUnitEnum(String desc, String table, String object) {
        this.desc = desc;
        this.table = table;
        this.object = object;
    }

    public String getTable() {
        return table;
    }

    public String getDesc() {
        return desc;
    }

    public String getObject() {
        return object;
    }

    /**
     * 状态转换 toName
     *
     * @param p desc
     * @return name
     */
    public static String convertToName(String p) {
        for (OperationUnitEnum e : OperationUnitEnum.values()) {
            if (Objects.equals(p, e.getDesc())) {
                return e.name();
            }
        }
        return null;
    }
}
