From 90f9311b8f92d84533860e374c2a38c16f8a6e7d Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 30 Aug 2022 18:01:27 +0800 Subject: [PATCH] fix --- src/main/java/com/xcong/farmer/cms/core/handler/ArticlesDataParserHandler.java | 49 +++++++++++++++++++++++++++++++------------------ 1 files changed, 31 insertions(+), 18 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..f8bc219 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("文章列表解析"); +// 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