fix: post query sql. (#676)

pull/687/head
Ryan Wang 2020-03-16 22:04:44 +08:00 committed by GitHub
parent 4d431fd85d
commit fae1df3859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -45,7 +45,7 @@ public interface PostRepository extends BasePostRepository<Post>, JpaSpecificati
* @param slug post slug
* @return a optional of post
*/
@Query("select post from Post post where DateUtil.year(post.createTime) = :year and DateUtil.month(post.createTime) = :month and post.slug = :slug")
@Query("select post from Post post where year(post.createTime) = :year and month(post.createTime) = :month and post.slug = :slug")
Optional<Post> findBy(@Param("year") Integer year, @Param("month") Integer month, @Param("slug") String slug);
/**
@ -57,7 +57,7 @@ public interface PostRepository extends BasePostRepository<Post>, JpaSpecificati
* @param status post status
* @return a optional of post
*/
@Query("select post from Post post where DateUtil.year(post.createTime) = :year and DateUtil.month(post.createTime) = :month and post.slug = :slug and post.status = :status")
@Query("select post from Post post where year(post.createTime) = :year and month(post.createTime) = :month and post.slug = :slug and post.status = :status")
Optional<Post> findBy(@Param("year") Integer year, @Param("month") Integer month, @Param("slug") String slug, @Param("status") PostStatus status);
/**
@ -69,7 +69,7 @@ public interface PostRepository extends BasePostRepository<Post>, JpaSpecificati
* @param slug post slug
* @return a optional of post
*/
@Query("select post from Post post where DateUtil.year(post.createTime) = :year and DateUtil.month(post.createTime) = :month and DateUtil.dayOfMonth(post.createTime) = :day and post.slug = :slug")
@Query("select post from Post post where year(post.createTime) = :year and month(post.createTime) = :month and day(post.createTime) = :day and post.slug = :slug")
Optional<Post> findBy(@Param("year") Integer year, @Param("month") Integer month, @Param("day") Integer day, @Param("slug") String slug);
/**
@ -82,6 +82,6 @@ public interface PostRepository extends BasePostRepository<Post>, JpaSpecificati
* @param status post status
* @return a optional of post
*/
@Query("select post from Post post where DateUtil.year(post.createTime) = :year and DateUtil.month(post.createTime) = :month and DateUtil.dayOfMonth(post.createTime) = :day and post.slug = :slug and post.status = :status")
@Query("select post from Post post where year(post.createTime) = :year and month(post.createTime) = :month and day(post.createTime) = :day and post.slug = :slug and post.status = :status")
Optional<Post> findBy(@Param("year") Integer year, @Param("month") Integer month, @Param("day") Integer day, @Param("slug") String slug, @Param("status") PostStatus status);
}