| | |
| | | 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())) { |
| | | |
| | | article.setColumnCode(param.getCode()); |
| | | |
| | | } else { |
| | | List<String> colIdsStr = StrUtil.split(param.getColId(), ','); |
| | | List<Long> colIds = new ArrayList<>(); |
| | |
| | | } |
| | | article.setCompanyId(companyId); |
| | | |
| | | Integer releaseType = (Integer) node.getSystemDataValue("releaseType"); |
| | | article.setReleaseType(releaseType); |
| | | 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); |
| | | 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"); |
| | | } |
| | | |
| | | |