package com.enterprise.manage.core.config;

import com.enterprise.manage.core.freemarker.SecureTag;
import com.enterprise.manage.core.freemarker.SystemDictionary;
import freemarker.template.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * Freemarker Config (freemarker 模版引擎配置)
 *
 * @author PeiZhi Guo
 * 2021-3-22 16:46
 */
@Component
public class FreemarkerConfig {

    @Resource
    private Configuration configuration;

    @Resource
    private SecureTag secureTag;

    @Resource
    private SystemDictionary systemDictionary;

    @PostConstruct
    public void setSharedVariable() {

        configuration.setSharedVariable("security", secureTag);

        // 系统字典标签
        configuration.setSharedVariable("dict", systemDictionary);
    }
}
