package com.webchat.common.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author: 程序员王七七 https://www.coderutil.com 网站作者
 * @Date: 2021-7-24 0024 23:01
 * @Description: 无描述信息
 */
@Getter
public enum ContentConfigEnum {

    MESSAGE_MOMENT_COMMENT("动态评论消息", "userName", "bbsContent"),
    MESSAGE_MOMENT_COMMENT_REPLY("动态下评论回复消息", "userName", "bbsContent", "commentContent");

    /***
     * 模板名称
     */
    private String configName;

    /***
     * 替换的变量名
     */
    private String[] vars;

    ContentConfigEnum(String configName, String ... vars) {
        this.configName = configName;
        this.vars = vars;
    }

    public static String[] getVars(String code) {
        String[] vars = new String[0];
        if (StringUtils.isBlank(code)) {
            return vars;
        }
        for (ContentConfigEnum config : ContentConfigEnum.values()) {
            if (config.name().equals(code)) {
                return config.vars;
            }
        }
        return vars;
    }
}
