From 5e54f37b9bfd01874c22c017c768adb2f8fee24d Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Tue, 12 Jul 2022 11:47:39 +0800
Subject: [PATCH] fix column update
---
src/main/java/com/xcong/farmer/cms/core/handler/ArticlesDataParserHandler.java | 47 ++++++++++++++++++++++++++++++-----------------
1 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/src/main/java/com/xcong/farmer/cms/core/handler/ArticlesDataParserHandler.java b/src/main/java/com/xcong/farmer/cms/core/handler/ArticlesDataParserHandler.java
index 2a0f273..df2f1e9 100644
--- a/src/main/java/com/xcong/farmer/cms/core/handler/ArticlesDataParserHandler.java
+++ b/src/main/java/com/xcong/farmer/cms/core/handler/ArticlesDataParserHandler.java
@@ -27,41 +27,54 @@
public class ArticlesDataParserHandler implements DataParserHandler {
private ArticleMapper articleMapper = SpringContextHolder.getBean(ArticleMapper.class);
- private CmsProperties cmsProperties = SpringContextHolder.getBean(CmsProperties.class);
@Override
public void dataParser(AttrNode node) {
log.info("文章列表解析");
Long companyId = (Long) node.getSystemDataValue("companyId");
+ String companyCode = (String) node.getSystemDataValue("companyCode");
+ String baseUrl = (String) node.getSystemDataValue("baseUrl");
+
Articles param = (Articles) node.getParam();
-
+ ArticleEntity article = new ArticleEntity();
+ Page<ArticleEntity> page = new Page<>(Integer.parseInt(param.getPage()), Integer.parseInt(param.getLimit()));
if (StrUtil.isEmpty(param.getColId())) {
- Page<ArticleEntity> page = new Page<>(Integer.parseInt(param.getPage()), Integer.parseInt(param.getLimit()));
-
- ArticleEntity article = new ArticleEntity();
article.setColumnCode(param.getCode());
- article.setCompanyId(companyId);
- IPage<ArticleEntity> listPage = articleMapper.selectArticleInPage(page, article);
-
- List<ArticleData> list = new ArrayList<>();
- for (ArticleEntity record : listPage.getRecords()) {
- ArticleData articleData = entityToData(record);
- list.add(articleData);
- }
-
- node.setData(list);
} else {
+ List<String> colIdsStr = StrUtil.split(param.getColId(), ',');
+ List<Long> colIds = new ArrayList<>();
+ colIdsStr.forEach(item -> {
+ colIds.add(Long.parseLong(item));
+ });
+ article.setColumnIds(colIds);
}
+ article.setCompanyId(companyId);
+
+ if (StrUtil.isNotBlank(param.getType())) {
+ if ("hot".equals(param.getType())) {
+ article.setIsTop(1);
+ }
+ }
+
+ IPage<ArticleEntity> listPage = articleMapper.selectArticleInPage(page, article);
+
+ List<ArticleData> list = new ArrayList<>();
+ for (ArticleEntity record : listPage.getRecords()) {
+ ArticleData articleData = entityToData(record, baseUrl);
+ list.add(articleData);
+ }
+
+ node.setData(list);
}
- public ArticleData entityToData(ArticleEntity article) {
+ public ArticleData entityToData(ArticleEntity article, String baseUrl) {
ArticleData articleData = ArticleConversion.INSTANCE.entityToData(article);
if (article.getType() == 2) {
articleData.setUrl(article.getArticleUrl());
} else {
- articleData.setUrl(cmsProperties.getBaseUrl() + article.getPath() + "/" + article.getId() + ".html");
+ articleData.setUrl(baseUrl + article.getPath() + "/" + article.getId() + ".html");
}
--
Gitblit v1.9.1