From 51ea662e22121f9a0ddb5b40c4a8e93e098b34ec Mon Sep 17 00:00:00 2001
From: Hentua <wangdoubleone@gmail.com>
Date: Wed, 10 Jan 2024 22:22:44 +0800
Subject: [PATCH] fxi
---
src/main/java/com/xcong/farmer/cms/core/handler/ArticlesDataParserHandler.java | 64 +++++++++++++++++++++-----------
1 files changed, 42 insertions(+), 22 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..4c7ed9b 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,61 @@
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("文章列表解析");
+// log.info("文章列表解析");
Long companyId = (Long) node.getSystemDataValue("companyId");
+ String companyCode = (String) node.getSystemDataValue("companyCode");
+ String baseUrl = (String) node.getSystemDataValue("baseUrl");
+ Object pageNo = node.getSystemDataValue("page");
+
Articles param = (Articles) node.getParam();
-
- 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 {
-
+ if (pageNo != null) {
+ param.setPage(pageNo.toString());
}
+
+ ArticleEntity article = new ArticleEntity();
+ Page<ArticleEntity> page = new Page<>(Integer.parseInt(param.getPage()), Integer.parseInt(param.getLimit()));
+ if (StrUtil.isEmpty(param.getColId())) {
+ article.setColumnCode(param.getCode());
+ } 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);
+ article.setDelStatus(ArticleEntity.DELETE_STATUS_NO);
+ article.setDraftState(2);
+
+ 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