diff --git a/src/main/java/run/halo/app/controller/content/ContentFeedController.java b/src/main/java/run/halo/app/controller/content/ContentFeedController.java index 5fb94d754ab7dccfb5dffed64b139bc3a58152f4..6d31043c22f08afe8db11a0f151dcd6897408922 100644 --- a/src/main/java/run/halo/app/controller/content/ContentFeedController.java +++ b/src/main/java/run/halo/app/controller/content/ContentFeedController.java @@ -2,6 +2,7 @@ package run.halo.app.controller.content; import freemarker.template.Template; import freemarker.template.TemplateException; +import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; import run.halo.app.model.entity.Post; import run.halo.app.model.enums.PostStatus; +import run.halo.app.model.vo.PostListVO; import run.halo.app.service.OptionService; import run.halo.app.service.PostService; @@ -140,11 +142,14 @@ public class ContentFeedController { * @param pageable pageable * @return List */ - private List buildPosts(Pageable pageable) { + private List buildPosts(Pageable pageable) { if (pageable == null) { - return postService.listAllBy(PostStatus.PUBLISHED); + Page postPage = postService.pageBy(PostStatus.PUBLISHED, null); + return postService.convertToListVo(postPage).getContent(); } - return postService.pageBy(PostStatus.PUBLISHED, pageable).map(postService::filterIfEncrypt).getContent(); + Page postPage = postService.pageBy(PostStatus.PUBLISHED, pageable); + Page posts = postService.convertToListVo(postPage); + return posts.getContent(); } } diff --git a/src/main/java/run/halo/app/controller/content/ContentTagController.java b/src/main/java/run/halo/app/controller/content/ContentTagController.java index a2e8428d091a8f82d904cc5dd852c1fc1154ebbc..b506e5a20027f75abd5add1f566937d4e17682a7 100644 --- a/src/main/java/run/halo/app/controller/content/ContentTagController.java +++ b/src/main/java/run/halo/app/controller/content/ContentTagController.java @@ -13,10 +13,8 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import run.halo.app.model.entity.Post; import run.halo.app.model.entity.Tag; -import run.halo.app.service.OptionService; -import run.halo.app.service.PostTagService; -import run.halo.app.service.TagService; -import run.halo.app.service.ThemeService; +import run.halo.app.model.vo.PostListVO; +import run.halo.app.service.*; import static org.springframework.data.domain.Sort.Direction.DESC; @@ -32,14 +30,21 @@ public class ContentTagController { private final TagService tagService; + private final PostService postService; + private final PostTagService postTagService; private final OptionService optionService; private final ThemeService themeService; - public ContentTagController(TagService tagService, PostTagService postTagService, OptionService optionService, ThemeService themeService) { + public ContentTagController(TagService tagService, + PostService postService, + PostTagService postTagService, + OptionService optionService, + ThemeService themeService) { this.tagService = tagService; + this.postService = postService; this.postTagService = postTagService; this.optionService = optionService; this.themeService = themeService; @@ -84,7 +89,8 @@ public class ContentTagController { Tag tag = tagService.getBySlugNameOfNonNull(slugName); final Pageable pageable = PageRequest.of(page - 1, optionService.getPostPageSize(), sort); - Page posts = postTagService.pagePostsBy(tag.getId(), pageable); + Page postPage = postTagService.pagePostsBy(tag.getId(), pageable); + Page posts = postService.convertToListVo(postPage); final int[] rainbow = PageUtil.rainbow(page, posts.getTotalPages(), 3); model.addAttribute("is_tags", true); diff --git a/src/main/resources/templates/common/web/atom.ftl b/src/main/resources/templates/common/web/atom.ftl index 7c6e38a18b7eff3558ecd2a507bbc43f2f54f9f9..cb5f365c3577bfcbfc4230992885ece18584749b 100644 --- a/src/main/resources/templates/common/web/atom.ftl +++ b/src/main/resources/templates/common/web/atom.ftl @@ -22,7 +22,7 @@ ${post.title!} ${options.blog_url!}/archives/${post.url!} ${options.blog_url!}/archives/${post.url!}#comments - ${post.createTime} + ${post.createTime!} <#if post.categories?? && post.categories?size gt 0> @@ -40,7 +40,7 @@ ${post.formatContent!} ]]> - ${post.comments?size} + ${post.commentCount!0}