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>
  • Method Summary

    Modifier and Type
    Method
    Description
     
    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)
     
    void
     
    void
     

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save

    Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

    deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor

    count, delete, exists, findAll, findAll, findAll, findBy, findOne

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll

    Methods 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

      Integer countByUserId(Long userId)
    • 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)