fix
Helius
2022-08-04 876e250c27eeca4df0c13c3d222103afd9e06b7e
fix
7 files modified
126 ■■■■■ changed files
src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java 5 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/core/node/PartNode.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/core/node/Template.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/core/tag/model/Include.java 22 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/core/controller/CmsCoreController.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java 22 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java 50 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/farmer/cms/core/node/AttrNode.java
@@ -106,7 +106,6 @@
            i++;
            try {
                Template.TAGS.add(tagsEnum.getName());
                // {id=${col.id}, page=1, limit=5, field=art} ${col.id} 形式需先设置值
                String tagValue = attributes.get(tagsEnum.getName());
                tagValue = attrValueFormat(tagValue);
@@ -135,10 +134,6 @@
    public void runDataInject() {
        Attributes attributes = this.element.attributes();
        for (Attribute attribute : attributes) {
            if (attribute.getKey().startsWith("\\$")) {
                Template.TAGS.add(attribute.getKey());
            }
            String key = attribute.getKey().replaceAll("\\$", "");
            String value = attribute.getValue();
src/main/java/com/xcong/farmer/cms/core/node/PartNode.java
@@ -30,7 +30,6 @@
        AttrNode attrNode = new AttrNode(element, tagDataMap);
        attrNode.systemData(this.system);
        attrNode.parser();
//        attrNode.runDataInject();
        StringBuilder result = new StringBuilder();
        if (CollUtil.isNotEmpty(element.children())) {
src/main/java/com/xcong/farmer/cms/core/node/Template.java
@@ -24,22 +24,15 @@
    private String path = "";
    private Document document;
    private Map<String, Map<String, Object>> params = new HashMap<>();
    private Map<String, Object> system;
    private List<PartNode> partNodes = new ArrayList<>();
    // 页面中包含的标签
    public static Set<String> TAGS;
    public volatile static boolean HAS_PAGING = false;
    public Template() {
        TAGS = new HashSet<>();
    }
    public Template(File file, Map<String, Object> system) {
        TAGS = new HashSet<>();
        Document document = null;
        try {
            document = Jsoup.parse(file, "utf-8");
@@ -156,14 +149,6 @@
    public List<PartNode> getPartNodes() {
        return partNodes;
    }
    public Map<String, Map<String, Object>> getParams() {
        return params;
    }
    public void putParams(String key, Map<String, Object> value) {
        this.params.put(key, value);
    }
    public void systemData(Map<String, Object> data) {
src/main/java/com/xcong/farmer/cms/core/tag/model/Include.java
@@ -1,27 +1,29 @@
package com.xcong.farmer.cms.core.tag.model;
/**
 * $("#head").load("com/head.html");
 * @author wzy
 * @date 2022-06-23
 **/
public class Include {
    private String field;
    private String repeat = "1";
    private String id;
    public String getRepeat() {
        return repeat;
    private String name;
    public String getId() {
        return id;
    }
    public void setRepeat(String repeat) {
        this.repeat = repeat;
    public void setId(String id) {
        this.id = id;
    }
    public String getField() {
        return field;
    public String getName() {
        return name;
    }
    public void setField(String field) {
        this.field = field;
    public void setName(String name) {
        this.name = name;
    }
}
src/main/java/com/xcong/farmer/cms/modules/core/controller/CmsCoreController.java
@@ -18,7 +18,7 @@
 **/
@Slf4j
@RestController
@RequestMapping(value = "/api")
@RequestMapping(value = "/cms")
@Api(value = "CmsCoreController", tags = "CMS核心类")
public class CmsCoreController {
@@ -28,7 +28,8 @@
    @ApiOperation(value = "发布文章", notes = "发布文章")
    @PostMapping(value = "releaseArticle/{id}")
    public Result releaseArticle(@PathVariable("id") Long id) {
        Long companyId = LoginUserUtil.getCompanyId();
//        Long companyId = LoginUserUtil.getCompanyId();
        Long companyId = 24L;
        releaseService.releaseArticle(id, companyId);
        return Result.ok("success");
    }
@@ -36,7 +37,8 @@
    @ApiOperation(value = "发布栏目", notes = "发布栏目")
    @PostMapping(value = "releaseColumn/{type}/{id}")
    public Result releaseColumn(@PathVariable("id") Long id, @PathVariable("type") Integer type) {
        Long companyId = LoginUserUtil.getCompanyId();
//        Long companyId = LoginUserUtil.getCompanyId();
        Long companyId = 24L;
        releaseService.releaseColumn(id, type, companyId);
        return Result.ok("success");
    }
@@ -44,7 +46,8 @@
    @ApiOperation(value = "发布首页", notes = "发布首页")
    @PostMapping(value = "/releaseIndex")
    public Result releaseIndex() {
        Long companyId = LoginUserUtil.getCompanyId();
//        Long companyId = LoginUserUtil.getCompanyId();
        Long companyId = 24L;
        releaseService.releaseIndex(companyId, true);
        return Result.ok("success");
    }
src/main/java/com/xcong/farmer/cms/modules/core/service/impl/CmsCoreServiceImpl.java
@@ -32,6 +32,8 @@
    @Autowired
    private WebSetMapper webSetMapper;
    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) {
@@ -44,7 +46,10 @@
        }
        try {
            cfg.process(data, templateName);
            String finalTemplateName = templateName;
            executor.execute(() -> {
                cfg.process(data, finalTemplateName);
            });
        } catch (Exception e) {
            e.printStackTrace();
            log.error("发布文章出错", e);
@@ -85,7 +90,10 @@
        }
        try {
            cfg.process(data, templateName);
            String finalTemplateName = templateName;
            executor.execute(() -> {
                cfg.process(data, finalTemplateName);
            });
        } catch (Exception e) {
            e.printStackTrace();
            log.error("发布栏目错误", e);
@@ -101,7 +109,10 @@
        }
        try {
            cfg.process(data, templateName);
            String finalTemplateName = templateName;
            executor.execute(() -> {
                cfg.process(data, finalTemplateName);
            });
        } catch (Exception e) {
            e.printStackTrace();
            log.error("发布首页错误", e);
@@ -122,7 +133,10 @@
        }
        try {
            cfg.process(data, templateName);
            String finalTemplateName = templateName;
            executor.execute(() -> {
                cfg.process(data, finalTemplateName);
            });
        } catch (Exception e) {
            e.printStackTrace();
            log.error("发布错误", e);
src/main/java/com/xcong/farmer/cms/modules/system/service/Impl/ReleaseServiceImpl.java
@@ -57,6 +57,39 @@
    private final Executor executor = new ThreadPoolExecutor(5, 20, 600, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
//    @Override
//    public void releaseArticle(Long id, Long companyId) {
//        ArticleEntity article = articleMapper.selectById(id);
//        ColumnEntity column = columnMapper.selectById(article.getColumnId());
//
//        Long beforeColumnId = article.getBeforeColumnId();
//        article.setBeforeColumnId(-1L);
//        articleMapper.updateById(article);
//
//        Map<String, Object> data = new Hashtable<>();
//        data.put("id", article.getId());
//        data.put("companyId", companyId);
//
//        executor.execute(() -> {
//            log.info("执行文章发布");
//            cmsCoreService.articleProcess(data, column.getArticleTemplate(), column.getPath());
//            this.releaseColumn(column.getId(), 1, companyId);
//            if (column.getParentId() != 0L) {
//                releaseColumn(column.getParentId(), 1, companyId);
//            }
//
//            if (beforeColumnId != null && !article.getColumnId().equals(beforeColumnId)) {
//                ColumnEntity beforeColumn = columnMapper.selectById(beforeColumnId);
//                this.releaseColumn(beforeColumnId, 1, companyId);
//                if (beforeColumn.getParentId() != 0L) {
//                    this.releaseColumn(beforeColumn.getParentId(), 1, companyId);
//                }
//            }
//
//            this.releaseIndex(companyId, false);
//        });
//    }
    @Override
    public void releaseArticle(Long id, Long companyId) {
        ArticleEntity article = articleMapper.selectById(id);
@@ -70,9 +103,9 @@
        data.put("id", article.getId());
        data.put("companyId", companyId);
        executor.execute(() -> {
            log.info("执行文章发布");
            cmsCoreService.articleProcess(data, column.getArticleTemplate(), column.getPath());
            this.releaseColumn(column.getId(), 1, companyId);
            if (column.getParentId() != 0L) {
                releaseColumn(column.getParentId(), 1, companyId);
@@ -87,7 +120,6 @@
            }
            this.releaseIndex(companyId, false);
        });
    }
    @Override
@@ -95,6 +127,7 @@
        ColumnEntity columnEntity = columnMapper.selectById(id);
        Map<String, Object> map = buildColumnData(columnEntity);
        // 判断栏目是否编辑了栏目编码或者修改了父级栏目
        if (columnEntity.getBeforeParentId() != -1 || !"-1".equals(columnEntity.getBeforeColumnCode())) {
            CompanyEntity company = companyMapper.selectById(companyId);
            if (!"-1".equals(columnEntity.getBeforeColumnCode())) {
@@ -117,7 +150,6 @@
            return;
        }
        executor.execute(() -> {
            List<ArticleEntity> articles = articleMapper.selectArticleByColumnId(columnEntity.getId(), companyId, type);
            if (CollUtil.isNotEmpty(articles)) {
                for (ArticleEntity article : articles) {
@@ -144,17 +176,15 @@
            }
            releaseIndex(companyId, false);
        });
        if (type != 1) {
            executor.execute(() -> {
                if (columnEntity.getParentId() == 0L) {
                    List<ColumnEntity> columns = columnMapper.selectColumnByParentId(columnEntity.getId(), companyId, 2);
                    if (CollUtil.isNotEmpty(columns)) {
                        for (ColumnEntity column : columns) {
                            List<ArticleEntity> articles = articleMapper.selectArticleByColumnId(column.getId(), companyId, type);
                            if (CollUtil.isNotEmpty(articles)) {
                                for (ArticleEntity article : articles) {
                        List<ArticleEntity> articleList = articleMapper.selectArticleByColumnId(column.getId(), companyId, type);
                        if (CollUtil.isNotEmpty(articleList)) {
                            for (ArticleEntity article : articleList) {
                                    if (article.getReleaseStatus() == 0) {
                                        article.setReleaseStatus(1);
                                        articleMapper.updateById(article);
@@ -174,8 +204,6 @@
                }
                releaseIndex(companyId, false);
            });
        }
    }
@@ -217,10 +245,8 @@
        cmsCoreService.indexProcess(map, webSetting.getIndexTemplate());
        if (hasSearch) {
            executor.execute(() -> {
                cmsCoreService.process(map, "search", webSetting.getSearchTemplate());
                cmsCoreService.process(map, "message", webSetting.getMsgTemplate());
            });
        }
    }