package com.zsc.edu.gateway.modules.operationLog.entity;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.zsc.edu.gateway.common.enums.IState;
import lombok.Getter;

/**
 * @author lenovo
 */

@Getter
public enum FunctionTypeEnum implements IEnum<String>, IState<FunctionTypeEnum> {
    create("create", "create"),
    update("update", "update"),
    delete("delete", "delete"),
    other("other", "other");

    private final String code;
    private final String message;

    FunctionTypeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    @Override
    public String getValue() {
        return code;
    }

    @Override
    public String toString() {
        return this.message;
    }

    /**
     * 根据代码获取消息
     *
     * @param code 代码
     * @return 消息
     */
    public static String getMessageByCode(String code) {
        for (FunctionTypeEnum type : FunctionTypeEnum.values()) {
            if (type.getCode().equalsIgnoreCase(code)) {
                return type.getMessage();
            }
        }
        return other.getMessage();
    }
}
