mirror of https://github.com/halo-dev/halo
🎨 代码优化
parent
da923f3469
commit
d63f7943b4
|
@ -11,7 +11,7 @@
|
|||
</p>
|
||||
|
||||
------------------------------
|
||||
🇨🇳[简体中文](../README.md) | 🇺🇸English
|
||||
🇨🇳[简体中文](README.md) | 🇺🇸English
|
||||
|
||||
## Introduction
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
</p>
|
||||
|
||||
------------------------------
|
||||
🇨🇳简体中文 | 🇺🇸[English](./docs/README-en-US.md)
|
||||
🇨🇳简体中文 | 🇺🇸[English](README-en_US.md)
|
||||
|
||||
## 简介
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
if (StrUtil.isNotEmpty(themeValue) && !StrUtil.equals(themeValue, null)) {
|
||||
BaseController.THEME = themeValue;
|
||||
} else {
|
||||
//以防万一
|
||||
//如果没有设置主题,则默认
|
||||
BaseController.THEME = "anatole";
|
||||
}
|
||||
configuration.setSharedVariable("themeName", BaseController.THEME);
|
||||
|
|
|
@ -34,6 +34,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* 查询所有文章 根据文章类型
|
||||
*
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> findPostsByPostType(String postType);
|
||||
|
@ -43,6 +44,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
*
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostsByPostType(String postType, Pageable pageable);
|
||||
|
@ -52,6 +54,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
*
|
||||
* @param keyWord keyword
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> findByPostTitleLike(String keyWord, Pageable pageable);
|
||||
|
@ -62,6 +65,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostsByPostStatusAndPostType(Integer status, String postType, Pageable pageable);
|
||||
|
@ -71,6 +75,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
*
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> findPostsByPostStatusAndPostType(Integer status, String postType);
|
||||
|
@ -80,6 +85,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
*
|
||||
* @param postUrl 路径
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
Post findPostByPostUrlAndPostType(String postUrl, String postType);
|
||||
|
@ -89,30 +95,30 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
*
|
||||
* @param postId 文章编号
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
Post findPostByPostIdAndPostType(Long postId, String postType);
|
||||
|
||||
/**
|
||||
* 查询之后文章
|
||||
* 查询指定日期之前的文章
|
||||
*
|
||||
* @param postDate 发布时间
|
||||
* @param postStatus 0,1,2
|
||||
* @param postType post or page
|
||||
* @return List
|
||||
* @param postDate 日期
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
List<Post> findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(Date postDate, Integer postStatus, String postType);
|
||||
|
||||
@Query(value = "SELECT * FROM halo_post WHERE post_status = 0 AND post_type='post' AND post_date < :postDate ORDER BY post_date DESC LIMIT 1", nativeQuery = true)
|
||||
Post queryPrePost(Date postDate);
|
||||
|
||||
/**
|
||||
* 查询之前的文章
|
||||
* 查询指定日期之后的文章
|
||||
*
|
||||
* @param postDate 发布时间
|
||||
* @param postStatus 0,1,2
|
||||
* @param postType post or page
|
||||
* @return List
|
||||
* @param postDate 日期
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
List<Post> findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(Date postDate, Integer postStatus, String postType);
|
||||
@Query(value = "SELECT * FROM halo_post WHERE post_status = 0 AND post_type='post' AND post_date > :postDate ORDER BY post_date ASC LIMIT 1", nativeQuery = true)
|
||||
Post queryNextPost(Date postDate);
|
||||
|
||||
/**
|
||||
* 查询文章归档信息 根据年份和月份
|
||||
|
@ -132,32 +138,34 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
|
||||
|
||||
/**
|
||||
* @return List
|
||||
*
|
||||
* @Author Aquan
|
||||
* @Description 查询文章归档信息 查询所有文章
|
||||
* @Date 2019.1.4 11:19
|
||||
* @Param
|
||||
* @return List
|
||||
**/
|
||||
@Query(value = "SELECT *,YEAR(post_date) AS YEAR FROM halo_post WHERE post_status=0 AND post_type='post' ORDER BY post_date DESC", nativeQuery = true)
|
||||
List<Post> findAllPost();
|
||||
|
||||
/**
|
||||
* @return Integer
|
||||
*
|
||||
* @Author Aquan
|
||||
* @Description 查询文章总数
|
||||
* @Date 2019.1.4 15:03
|
||||
* @Param
|
||||
* @return Integer
|
||||
**/
|
||||
@Query(value = "SELECT count(1) AS COUNT FROM halo_post WHERE post_status=0 AND post_type='post'", nativeQuery = true)
|
||||
Integer totalAllPostCount();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据年份和月份查询文章
|
||||
*
|
||||
* @param year year
|
||||
* @param month month
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Query(value = "SELECT *,YEAR(post_date) AS YEAR,MONTH(post_date) AS MONTH FROM halo_post WHERE post_status=0 and post_type='post' AND YEAR(post_date)=:year AND MONTH(post_date)=:month ORDER BY post_date DESC", nativeQuery = true)
|
||||
|
@ -167,6 +175,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* 根据年份查询文章
|
||||
*
|
||||
* @param year year
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Query(value = "SELECT *,YEAR(post_date) AS YEAR FROM halo_post WHERE post_status=0 AND post_type='post' AND YEAR(post_date)=:year ORDER BY post_date DESC", nativeQuery = true)
|
||||
|
@ -178,6 +187,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* @param year year
|
||||
* @param month month
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
@Query(value = "SELECT * FROM halo_post WHERE post_status=0 and post_type='post' AND YEAR(post_date)=:year AND MONTH(post_date)=:month ORDER BY post_date DESC", countQuery = "SELECT COUNT(*) FROM halo_post WHERE post_status=0 AND YEAR(post_date)=:year AND MONTH(post_date)=:month", nativeQuery = true)
|
||||
|
@ -189,6 +199,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* @param category category
|
||||
* @param status status
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostByCategoriesAndPostStatus(Category category, Integer status, Pageable pageable);
|
||||
|
@ -199,6 +210,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* @param tag tag
|
||||
* @param status status
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostsByTagsAndPostStatus(Tag tag, Integer status, Pageable pageable);
|
||||
|
@ -207,6 +219,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* 根据标签查询文章
|
||||
*
|
||||
* @param tag tag
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> findPostsByTags(Tag tag);
|
||||
|
@ -216,6 +229,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
*
|
||||
* @param keyword 关键词
|
||||
* @param pageable 分页信息
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
@Query(value = "SELECT * FROM halo_post WHERE post_status = 0 AND post_type='post' AND post_title LIKE '%=:keyword%' OR post_content LIKE '%=:keyword%'", nativeQuery = true)
|
||||
|
@ -225,6 +239,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* 按热度从大到小排序
|
||||
*
|
||||
* @param postStatus 文章状态
|
||||
*
|
||||
* @return List<Post>
|
||||
*/
|
||||
List<Post> findPostsByPostTypeOrderByPostViewsDesc(String postStatus);
|
||||
|
@ -242,6 +257,7 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
*
|
||||
* @param status 文章状态
|
||||
* @param postType 文章类型
|
||||
*
|
||||
* @return 文章数量
|
||||
*/
|
||||
Integer countAllByPostStatusAndPostType(Integer status, String postType);
|
||||
|
@ -250,8 +266,9 @@ public interface PostRepository extends JpaRepository<Post, Long> {
|
|||
* 获取指定条数的文章
|
||||
*
|
||||
* @param limit 条数
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Query(value = "SELECT * FROM halo_post WHERE post_status = 0 AND post_type = 'post' ORDER BY post_date DESC LIMIT :limit",nativeQuery = true)
|
||||
@Query(value = "SELECT * FROM halo_post WHERE post_status = 0 AND post_type = 'post' ORDER BY post_date DESC LIMIT :limit", nativeQuery = true)
|
||||
List<Post> getPostsByLimit(@Param(value = "limit") int limit);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public interface PostService {
|
|||
* 新增文章
|
||||
*
|
||||
* @param post Post
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
Post save(Post post);
|
||||
|
@ -34,6 +35,7 @@ public interface PostService {
|
|||
* 根据编号删除文章
|
||||
*
|
||||
* @param postId postId
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
Post remove(Long postId);
|
||||
|
@ -43,6 +45,7 @@ public interface PostService {
|
|||
*
|
||||
* @param postId postId
|
||||
* @param status status
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
Post updatePostStatus(Long postId, Integer status);
|
||||
|
@ -58,6 +61,7 @@ public interface PostService {
|
|||
* 获取文章列表 不分页
|
||||
*
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> findAll(String postType);
|
||||
|
@ -67,6 +71,7 @@ public interface PostService {
|
|||
*
|
||||
* @param keyWord keyword
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> searchPosts(String keyWord, Pageable pageable);
|
||||
|
@ -77,6 +82,7 @@ public interface PostService {
|
|||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostByStatus(Integer status, String postType, Pageable pageable);
|
||||
|
@ -85,6 +91,7 @@ public interface PostService {
|
|||
* 根据文章状态查询 分页,首页分页
|
||||
*
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostByStatus(Pageable pageable);
|
||||
|
@ -94,6 +101,7 @@ public interface PostService {
|
|||
*
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> findPostByStatus(Integer status, String postType);
|
||||
|
@ -102,6 +110,7 @@ public interface PostService {
|
|||
* 根据编号查询文章
|
||||
*
|
||||
* @param postId postId
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
Optional<Post> findByPostId(Long postId);
|
||||
|
@ -111,6 +120,7 @@ public interface PostService {
|
|||
*
|
||||
* @param postId postId
|
||||
* @param postType postType
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
Post findByPostId(Long postId, String postType);
|
||||
|
@ -120,6 +130,7 @@ public interface PostService {
|
|||
*
|
||||
* @param postUrl 路径
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
Post findByPostUrl(String postUrl, String postType);
|
||||
|
@ -132,20 +143,22 @@ public interface PostService {
|
|||
List<Post> findPostLatest();
|
||||
|
||||
/**
|
||||
* 查询Id之后的文章
|
||||
* 获取下一篇文章 较新
|
||||
*
|
||||
* @param postDate postDate
|
||||
* @return List
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
List<Post> findByPostDateAfter(Date postDate);
|
||||
Post getNextPost(Date postDate);
|
||||
|
||||
/**
|
||||
* 查询Id之前的文章
|
||||
* 获取下一篇文章 较老
|
||||
*
|
||||
* @param postDate postDate
|
||||
* @return List
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
List<Post> findByPostDateBefore(Date postDate);
|
||||
Post getPrePost(Date postDate);
|
||||
|
||||
/**
|
||||
* 查询归档信息 根据年份和月份
|
||||
|
@ -162,11 +175,12 @@ public interface PostService {
|
|||
List<Archive> findPostGroupByYear();
|
||||
|
||||
/**
|
||||
* @return List
|
||||
*
|
||||
* @Author Aquan
|
||||
* @Description 查询归档信息 查看所有文章
|
||||
* @Date 2019.1.4 11:14
|
||||
* @Param
|
||||
* @return List
|
||||
**/
|
||||
List<Archive> findAllPost();
|
||||
|
||||
|
@ -176,6 +190,7 @@ public interface PostService {
|
|||
*
|
||||
* @param year year
|
||||
* @param month month
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> findPostByYearAndMonth(String year, String month);
|
||||
|
@ -186,6 +201,7 @@ public interface PostService {
|
|||
* @param year year
|
||||
* @param month month
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostByYearAndMonth(String year, String month, Pageable pageable);
|
||||
|
@ -194,6 +210,7 @@ public interface PostService {
|
|||
* 根据年份查询文章
|
||||
*
|
||||
* @param year year
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> findPostByYear(String year);
|
||||
|
@ -203,6 +220,7 @@ public interface PostService {
|
|||
*
|
||||
* @param category category
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostByCategories(Category category, Pageable pageable);
|
||||
|
@ -212,6 +230,7 @@ public interface PostService {
|
|||
*
|
||||
* @param tag tag
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> findPostsByTags(Tag tag, Pageable pageable);
|
||||
|
@ -221,6 +240,7 @@ public interface PostService {
|
|||
*
|
||||
* @param keyword 关键词
|
||||
* @param pageable 分页信息
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
Page<Post> searchByKeywords(String keyword, Pageable pageable);
|
||||
|
@ -236,6 +256,7 @@ public interface PostService {
|
|||
* 当前文章的相似文章
|
||||
*
|
||||
* @param post post
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> relatedPosts(Post post);
|
||||
|
@ -251,6 +272,7 @@ public interface PostService {
|
|||
* 根据文章状态查询数量
|
||||
*
|
||||
* @param status 文章状态
|
||||
*
|
||||
* @return 文章数量
|
||||
*/
|
||||
Integer getCountByStatus(Integer status);
|
||||
|
@ -259,6 +281,7 @@ public interface PostService {
|
|||
* 生成rss
|
||||
*
|
||||
* @param posts posts
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String buildRss(List<Post> posts);
|
||||
|
@ -267,6 +290,7 @@ public interface PostService {
|
|||
* 生成sitemap
|
||||
*
|
||||
* @param posts posts
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String buildSiteMap(List<Post> posts);
|
||||
|
@ -284,6 +308,7 @@ public interface PostService {
|
|||
* @param post post
|
||||
* @param cateList cateList
|
||||
* @param tagList tagList
|
||||
*
|
||||
* @return Post Post
|
||||
*/
|
||||
Post buildCategoriesAndTags(Post post, List<String> cateList, @RequestParam("tagList") String tagList);
|
||||
|
@ -292,6 +317,7 @@ public interface PostService {
|
|||
* 获取最近的文章
|
||||
*
|
||||
* @param limit 条数
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
List<Post> getRecentPosts(int limit);
|
||||
|
|
|
@ -55,6 +55,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 保存文章
|
||||
*
|
||||
* @param post Post
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
@Override
|
||||
|
@ -67,6 +68,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 根据编号移除文章
|
||||
*
|
||||
* @param postId postId
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
@Override
|
||||
|
@ -82,6 +84,7 @@ public class PostServiceImpl implements PostService {
|
|||
*
|
||||
* @param postId postId
|
||||
* @param status status
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
@Override
|
||||
|
@ -116,6 +119,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 获取文章列表 不分页
|
||||
*
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
|
@ -129,6 +133,7 @@ public class PostServiceImpl implements PostService {
|
|||
*
|
||||
* @param keyWord keyword
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
|
@ -142,6 +147,7 @@ public class PostServiceImpl implements PostService {
|
|||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
* @param pageable 分页信息
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
@Override
|
||||
|
@ -153,6 +159,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 根据文章状态查询 分页,首页分页
|
||||
*
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
@Override
|
||||
|
@ -166,6 +173,7 @@ public class PostServiceImpl implements PostService {
|
|||
*
|
||||
* @param status 0,1,2
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
|
@ -178,6 +186,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 根据编号查询文章
|
||||
*
|
||||
* @param postId postId
|
||||
*
|
||||
* @return Optional
|
||||
*/
|
||||
@Override
|
||||
|
@ -189,6 +198,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 根据编号和类型查询文章
|
||||
*
|
||||
* @param postId postId
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
@Override
|
||||
|
@ -201,6 +211,7 @@ public class PostServiceImpl implements PostService {
|
|||
*
|
||||
* @param postUrl 路径
|
||||
* @param postType post or page
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
@Override
|
||||
|
@ -221,28 +232,29 @@ public class PostServiceImpl implements PostService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 查询之后的文章
|
||||
* 获取下一篇文章 较新
|
||||
*
|
||||
* @param postDate 发布时间
|
||||
* @return List
|
||||
* @param postDate postDate
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
@Override
|
||||
public List<Post> findByPostDateAfter(Date postDate) {
|
||||
return postRepository.findByPostDateAfterAndPostStatusAndPostTypeOrderByPostDateDesc(postDate, PostStatusEnum.PUBLISHED.getCode(), PostTypeEnum.POST_TYPE_POST.getDesc());
|
||||
public Post getNextPost(Date postDate) {
|
||||
return postRepository.queryNextPost(postDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询Id之前的文章
|
||||
* 获取下一篇文章 较老
|
||||
*
|
||||
* @param postDate 发布时间
|
||||
* @return List
|
||||
* @param postDate postDate
|
||||
*
|
||||
* @return Post
|
||||
*/
|
||||
@Override
|
||||
public List<Post> findByPostDateBefore(Date postDate) {
|
||||
return postRepository.findByPostDateBeforeAndPostStatusAndPostTypeOrderByPostDateAsc(postDate, PostStatusEnum.PUBLISHED.getCode(), PostTypeEnum.POST_TYPE_POST.getDesc());
|
||||
public Post getPrePost(Date postDate) {
|
||||
return postRepository.queryPrePost(postDate);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询归档信息 根据年份和月份
|
||||
*
|
||||
|
@ -287,11 +299,12 @@ public class PostServiceImpl implements PostService {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return List
|
||||
*
|
||||
* @Author Aquan
|
||||
* @Description 查询归档信息 返回所有文章
|
||||
* @Date 2019.1.4 11:16
|
||||
* @Param
|
||||
* @return List
|
||||
**/
|
||||
@Override
|
||||
@Cacheable(value = POSTS_CACHE_NAME, key = "'archives_all'")
|
||||
|
@ -314,6 +327,7 @@ public class PostServiceImpl implements PostService {
|
|||
*
|
||||
* @param year year
|
||||
* @param month month
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
|
@ -326,6 +340,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 根据年份查询文章
|
||||
*
|
||||
* @param year year
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
|
@ -340,6 +355,7 @@ public class PostServiceImpl implements PostService {
|
|||
* @param year year year
|
||||
* @param month month month
|
||||
* @param pageable pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
@Override
|
||||
|
@ -353,6 +369,7 @@ public class PostServiceImpl implements PostService {
|
|||
* @param category category
|
||||
* @param status status
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
@Override
|
||||
|
@ -367,6 +384,7 @@ public class PostServiceImpl implements PostService {
|
|||
* @param tag tag
|
||||
* @param status status
|
||||
* @param pageable pageable
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
@Override
|
||||
|
@ -380,6 +398,7 @@ public class PostServiceImpl implements PostService {
|
|||
*
|
||||
* @param keyword 关键词
|
||||
* @param pageable 分页信息
|
||||
*
|
||||
* @return Page
|
||||
*/
|
||||
@Override
|
||||
|
@ -402,6 +421,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 当前文章的相似文章
|
||||
*
|
||||
* @param post post
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
|
@ -439,6 +459,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 根据文章状态查询数量
|
||||
*
|
||||
* @param status 文章状态
|
||||
*
|
||||
* @return 文章数量
|
||||
*/
|
||||
@Override
|
||||
|
@ -450,6 +471,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 生成rss
|
||||
*
|
||||
* @param posts posts
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
|
@ -467,6 +489,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 生成sitemap
|
||||
*
|
||||
* @param posts posts
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
|
@ -494,6 +517,7 @@ public class PostServiceImpl implements PostService {
|
|||
* @param post post
|
||||
* @param cateList cateList
|
||||
* @param tagList tagList
|
||||
*
|
||||
* @return Post Post
|
||||
*/
|
||||
@Override
|
||||
|
@ -511,6 +535,7 @@ public class PostServiceImpl implements PostService {
|
|||
* 获取最近的文章
|
||||
*
|
||||
* @param limit 条数
|
||||
*
|
||||
* @return List
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -125,16 +125,17 @@ public class FrontArchiveController extends BaseController {
|
|||
}
|
||||
//获得当前文章的发布日期
|
||||
final Date postDate = post.getPostDate();
|
||||
//查询当前文章日期之前的所有文章
|
||||
final List<Post> beforePosts = postService.findByPostDateBefore(postDate);
|
||||
//查询当前文章日期之后的所有文章
|
||||
final List<Post> afterPosts = postService.findByPostDateAfter(postDate);
|
||||
|
||||
if (null != beforePosts && beforePosts.size() > 0) {
|
||||
model.addAttribute("beforePost", beforePosts.get(beforePosts.size() - 1));
|
||||
final Post prePost = postService.getPrePost(postDate);
|
||||
final Post nextPost = postService.getNextPost(postDate);
|
||||
if (null != prePost) {
|
||||
//兼容老版本主题
|
||||
model.addAttribute("beforePost", prePost);
|
||||
model.addAttribute("prePost",prePost);
|
||||
}
|
||||
if (null != afterPosts && afterPosts.size() > 0) {
|
||||
model.addAttribute("afterPost", afterPosts.get(afterPosts.size() - 1));
|
||||
if (null != nextPost) {
|
||||
//兼容老版本主题
|
||||
model.addAttribute("afterPost", nextPost);
|
||||
model.addAttribute("nextPost",nextPost);
|
||||
}
|
||||
List<Comment> comments = null;
|
||||
if (StrUtil.equals(HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()), TrueFalseEnum.TRUE.getDesc()) || HaloConst.OPTIONS.get(BlogPropertiesEnum.NEW_COMMENT_NEED_CHECK.getProp()) == null) {
|
||||
|
|
|
@ -79,14 +79,14 @@
|
|||
</div>
|
||||
<div class="pagination">
|
||||
<ul class="clearfix">
|
||||
<#if afterPost??>
|
||||
<#if nextPost??>
|
||||
<li class="pre pagbuttons">
|
||||
<a class="btn" role="navigation" href="/archives/${afterPost.postUrl}" title="${afterPost.postTitle}">上一篇</a>
|
||||
<a class="btn" role="navigation" href="/archives/${nextPost.postUrl}" title="${nextPost.postTitle}">上一篇</a>
|
||||
</li>
|
||||
</#if>
|
||||
<#if beforePost??>
|
||||
<#if prePost??>
|
||||
<li class="next pagbuttons">
|
||||
<a class="btn" role="navigation" href="/archives/${beforePost.postUrl}" title="${beforePost.postTitle}">下一篇</a>
|
||||
<a class="btn" role="navigation" href="/archives/${prePost.postUrl}" title="${prePost.postTitle}">下一篇</a>
|
||||
</li>
|
||||
</#if>
|
||||
</ul>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<nav class="material-nav mdl-color-text--grey-50 mdl-cell mdl-cell--12-col">
|
||||
|
||||
<!-- Prev Nav -->
|
||||
<#if afterPost??>
|
||||
<a href="/archives/${afterPost.postUrl!}" id="post_nav-newer" class="prev-content">
|
||||
<#if nextPost??>
|
||||
<a href="/archives/${nextPost.postUrl!}" id="post_nav-newer" class="prev-content">
|
||||
<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
|
||||
<i class="material-icons">arrow_back</i>
|
||||
</button>
|
||||
|
@ -14,8 +14,8 @@
|
|||
<div class="section-spacer"></div>
|
||||
|
||||
<!-- Next Nav -->
|
||||
<#if beforePost??>
|
||||
<a href="/archives/${beforePost.postUrl!}" id="post_nav-older" class="next-content">
|
||||
<#if prePost??>
|
||||
<a href="/archives/${prePost.postUrl!}" id="post_nav-older" class="next-content">
|
||||
旧篇
|
||||
|
||||
<button class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--icon mdl-color--white mdl-color-text--grey-900" role="presentation">
|
||||
|
|
Loading…
Reference in New Issue