Package com.bytedesk.forum.post
Interface PostRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<PostEntity,,Long> org.springframework.data.jpa.repository.JpaRepository<PostEntity,,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<PostEntity>,org.springframework.data.repository.ListCrudRepository<PostEntity,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<PostEntity,,Long> org.springframework.data.repository.PagingAndSortingRepository<PostEntity,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<PostEntity>,org.springframework.data.repository.Repository<PostEntity,Long>
public interface PostRepository
extends org.springframework.data.jpa.repository.JpaRepository<PostEntity,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<PostEntity>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
org.springframework.data.jpa.repository.JpaSpecificationExecutor.SpecificationFluentQuery<T extends Object> -
Method Summary
Modifier and TypeMethodDescriptioncountByUserId(Long userId) org.springframework.data.domain.Page<PostEntity>findByCategory(CategoryEntity category, org.springframework.data.domain.Pageable pageable) org.springframework.data.domain.Page<PostEntity>findByUserId(Long userId, org.springframework.data.domain.Pageable pageable) org.springframework.data.domain.Page<PostEntity>fullTextSearch(String keyword, org.springframework.data.domain.Pageable pageable) org.springframework.data.domain.Page<PostEntity>fullTextSearchByCategory(String keyword, Long categoryId, org.springframework.data.domain.Pageable pageable) voidincrementLikeCount(Long postId) voidincrementViewCount(Long postId) Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
count, delete, exists, findAll, findAll, findAll, findAll, findBy, findOneMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByCategory
org.springframework.data.domain.Page<PostEntity> findByCategory(CategoryEntity category, org.springframework.data.domain.Pageable pageable) -
findByUserId
org.springframework.data.domain.Page<PostEntity> findByUserId(Long userId, org.springframework.data.domain.Pageable pageable) -
countByUserId
-
incrementViewCount
@Modifying @Query("UPDATE PostEntity p SET p.viewCount = p.viewCount + 1 WHERE p.id = ?1") void incrementViewCount(Long postId) -
incrementLikeCount
@Modifying @Query("UPDATE PostEntity p SET p.likeCount = p.likeCount + 1 WHERE p.id = ?1") void incrementLikeCount(Long postId) -
fullTextSearch
@Query(value="SELECT * FROM bytedesk_post WHERE MATCH(title, content) AGAINST(:keyword IN BOOLEAN MODE)", countQuery="SELECT COUNT(*) FROM bytedesk_post WHERE MATCH(title, content) AGAINST(:keyword IN BOOLEAN MODE)", nativeQuery=true) org.springframework.data.domain.Page<PostEntity> fullTextSearch(@Param("keyword") String keyword, org.springframework.data.domain.Pageable pageable) -
fullTextSearchByCategory
@Query(value="SELECT * FROM bytedesk_forum_post WHERE MATCH(title, content) AGAINST(:keyword IN BOOLEAN MODE) AND category_id = :categoryId", countQuery="SELECT COUNT(*) FROM bytedesk_forum_post WHERE MATCH(title, content) AGAINST(:keyword IN BOOLEAN MODE) AND category_id = :categoryId", nativeQuery=true) org.springframework.data.domain.Page<PostEntity> fullTextSearchByCategory(@Param("keyword") String keyword, @Param("categoryId") Long categoryId, org.springframework.data.domain.Pageable pageable)
-