From 62d3f103086822a1bc51971a0733cb3d9b756bc0 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Mon, 22 Aug 2022 15:29:10 +0800
Subject: [PATCH] ifx

---
 src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java b/src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java
index 7a2eb81..71292cf 100644
--- a/src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java
+++ b/src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java
@@ -2,8 +2,13 @@
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
+import com.xcong.farmer.cms.common.contants.AppContants;
 import com.xcong.farmer.cms.core.template.TemplateConfiguration;
 import com.xcong.farmer.cms.modules.core.service.ICmsCoreService;
+import com.xcong.farmer.cms.modules.system.entity.ArticleEntity;
+import com.xcong.farmer.cms.modules.system.entity.ColumnEntity;
+import com.xcong.farmer.cms.modules.system.mapper.ArticleMapper;
+import com.xcong.farmer.cms.modules.system.mapper.ColumnMapper;
 import com.xcong.farmer.cms.modules.system.mapper.WebSetMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +37,13 @@
     @Autowired
     private WebSetMapper webSetMapper;
 
+    @Autowired
+    private ColumnMapper columnMapper;
+    @Autowired
+    private ArticleMapper articleMapper;
+
+//    private final Executor executor = new ThreadPoolExecutor(10, 20, 600, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
+
 
     @Override
     public void articleProcess(Map<String, Object> data, String templateName, String templatePath) {
@@ -39,12 +51,16 @@
         data.put("templatePath", templatePath);
         data.put("templateName", data.get("id"));
         globalData(data);
+
         if (StrUtil.isEmpty(templateName)) {
             templateName = "defualt.article.html";
         }
 
         try {
-            cfg.process(data, templateName);
+            String finalTemplateName = templateName;
+            AppContants.EXECUTOR.execute(() -> {
+                cfg.process(data, finalTemplateName);
+            });
         } catch (Exception e) {
             e.printStackTrace();
             log.error("发布文章出错", e);
@@ -85,7 +101,10 @@
         }
 
         try {
-            cfg.process(data, templateName);
+            String finalTemplateName = templateName;
+            AppContants.EXECUTOR.execute(() -> {
+                cfg.process(data, finalTemplateName);
+            });
         } catch (Exception e) {
             e.printStackTrace();
             log.error("发布栏目错误", e);
@@ -101,7 +120,10 @@
         }
 
         try {
-            cfg.process(data, templateName);
+            String finalTemplateName = templateName;
+            AppContants.EXECUTOR.execute(() -> {
+                cfg.process(data, finalTemplateName);
+            });
         } catch (Exception e) {
             e.printStackTrace();
             log.error("发布首页错误", e);
@@ -112,8 +134,20 @@
     public void process(Map<String, Object> data, String templateType, String templateName) {
         data.put("templateType", templateType);
         globalData(data);
+
+        if ("search".equals(templateType) && StrUtil.isBlank(templateName)) {
+            templateName = "search.html";
+        }
+
+        if ("message".equals(templateType) && StrUtil.isBlank(templateName)) {
+            templateName = "message.html";
+        }
+
         try {
-            cfg.process(data, templateName);
+            String finalTemplateName = templateName;
+            AppContants.EXECUTOR.execute(() -> {
+                cfg.process(data, finalTemplateName);
+            });
         } catch (Exception e) {
             e.printStackTrace();
             log.error("发布错误", e);
@@ -124,6 +158,18 @@
         Long companyId = (Long) data.get("companyId");
         Map<String, String> globalSetting = webSetMapper.selectSiteGlobalSetting(companyId);
 
+        String type = (String) data.get("templateType");
+        if ("column".equals(type)){
+            Long id = (Long) data.get("id");
+            ColumnEntity columnEntity = columnMapper.selectById(id);
+            globalSetting.put("title", columnEntity.getColumnName() + "_" + globalSetting.get("title"));
+        } else if ("article".equals(type)) {
+            Long id = (Long) data.get("id");
+            ArticleEntity article = articleMapper.selectById(id);
+            ColumnEntity columnEntity = columnMapper.selectById(article.getColumnId());
+            globalSetting.put("title", article.getTitle() + "_" + columnEntity.getColumnName() +"_" + globalSetting.get("title"));
+        }
+
         data.putAll(globalSetting);
     }
 }

--
Gitblit v1.9.1