package com.xcong.farmer.cms.modules.core.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.xcong.farmer.cms.core.template.TemplateConfiguration; import com.xcong.farmer.cms.modules.core.service.ICmsCoreService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.validation.constraints.NotNull; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.Executor; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** * @author wzy * @date 2022-07-03 **/ @Slf4j @Service public class CmsCoreServiceImpl implements ICmsCoreService { @Autowired private TemplateConfiguration cfg; @Override public void articleProcess(Map data, String templateName, String templatePath) { data.put("templateType", "article"); data.put("templatePath", templatePath); data.put("templateName", data.get("id")); if (StrUtil.isEmpty(templateName)) { templateName = "defualt.artile.html"; } cfg.process(data, templateName); } @Override public void articlesProcess(Map data, List ids, String templateName, String templatePath) { if (CollUtil.isEmpty(ids)) { return; } for (Long id : ids) { data.put("id", id); articleProcess(data, templateName, templatePath); } } @Override public void columnsProcess(Map data, List ids, String templateName) { if (CollUtil.isEmpty(ids)) { return; } for (Long id : ids) { data.put("id", id); columnProcess(data, templateName); } } @Override public void columnProcess(Map data, String templateName) { data.put("templateType", "column"); data.put("page", 1); if (StrUtil.isEmpty(templateName)) { templateName = "defualt.list.html"; } cfg.process(data, templateName); } @Override public void indexProcess(@NotNull Map data, String templateName) { if (StrUtil.isEmpty(templateName)) { templateName = "index.html"; } cfg.process(data, templateName); } }