更新文章时分类页面的不同数据

最后发布时间:2023-07-22 10:48:01 浏览量:
if(template.getTemplateData().equals(TemplateData.ARTICLE_TREE)){
            List<ContentVO> contents=listVoTree(ids,category.getIsDesc());
            articleListVo.setContents(contents);
        }else if(template.getTemplateData().equals(TemplateData.CATEGORY_CHILD_PAGE)){
            List<CategoryContentList> categoryContentLists = listCategoryChild(category.getId(), page);
            articleListVo.setCategoryContentLists(categoryContentLists);
            List<ContentVO> allVos = new ArrayList<>();
            for(CategoryContentList categoryContentList: categoryContentLists){
                List<ContentVO> contentVOS = categoryContentList.getContentVOS();
                allVos.addAll(contentVOS);
            }
            articleListVo.setContents(allVos);
        }else if(template.getTemplateData().equals(TemplateData.CATEGORY_CHILD_TREE)){
            List<CategoryContentList> categoryContentLists = listCategoryChild(category.getId());
            articleListVo.setCategoryContentLists(categoryContentLists);
            List<ContentVO> allVos = new ArrayList<>();
            for(CategoryContentList categoryContentList: categoryContentLists){
                List<ContentVO> contentVOS = categoryContentList.getContentVOS();
                allVos.addAll(contentVOS);
            }
            articleListVo.setContents(allVos);
        }else {
//            Page<Article> articles = pageArticleByCategoryIds(articleSpecification(ids,category.getIsDesc(), ArticleServiceImpl.ArticleList.NO_INCLUDE_TOP),PageRequest.of(page,category.getArticleListSize()));
            Page<Content> contentsPage = pageContentByCategoryIds(ids, category.getIsDesc(), PageRequest.of(page, category.getArticleListSize()));
            Page<ContentVO> contentVOS = convertToPageVo(contentsPage);
            int totalPages = contentVOS.getTotalPages();
            int size = contentVOS.getSize();
            long totalElements = contentVOS.getTotalElements();
            articleListVo.setTotalPages(totalPages);
            articleListVo.setSize(size);
            articleListVo.setTotalElements(totalElements);
            List<ContentVO> contents = contentVOS.getContent();
            articleListVo.setContents(contents);
        }