| | |
| | | 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 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; |
| | |
| | | |
| | | @Autowired |
| | | private TemplateConfiguration cfg; |
| | | private final Executor executor = new ThreadPoolExecutor(5, 10, 600, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); |
| | | |
| | | |
| | | @Override |
| | |
| | | templateName = "defualt.artile.html"; |
| | | } |
| | | |
| | | String finalTemplateName = templateName; |
| | | executor.execute(() -> cfg.process(data, finalTemplateName)); |
| | | cfg.process(data, templateName); |
| | | } |
| | | |
| | | @Override |
| | | public void articlesProcess(Map<String, Object> data, List<Long> 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<String, Object> data, List<Long> ids, String templateName) { |
| | | if (CollUtil.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | |
| | | for (Long id : ids) { |
| | | data.put("id", id); |
| | | columnProcess(data, templateName); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | templateName = "defualt.list.html"; |
| | | } |
| | | |
| | | String finalTemplateName = templateName; |
| | | executor.execute(() -> cfg.process(data, finalTemplateName)); |
| | | cfg.process(data, templateName); |
| | | } |
| | | |
| | | @Override |
| | |
| | | templateName = "index.html"; |
| | | } |
| | | |
| | | String finalTemplateName = templateName; |
| | | executor.execute(() -> cfg.process(data, finalTemplateName)); |
| | | cfg.process(data, templateName); |
| | | } |
| | | } |