package com.cm.common.util;

import com.cm.common.pojo.dtos.templateconfig.TemplateConfigDTO;
import com.cm.common.service.templateconfig.ITemplateConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class TemplateMapInit implements ApplicationRunner {

    @Autowired
    ITemplateConfigService iTemplateConfigService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        List<TemplateConfigDTO> list = iTemplateConfigService.listTemplateConfig(map);
        for (TemplateConfigDTO template: list) {
            TemplateUtil.getInstance().pushTemplate(template.getTemplateCode(), template);
        }
    }

}
