Interface PostsRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<PostBean,​java.lang.Integer>, org.springframework.data.jpa.repository.JpaRepository<PostBean,​java.lang.Integer>, org.springframework.data.repository.PagingAndSortingRepository<PostBean,​java.lang.Integer>, org.springframework.data.repository.query.QueryByExampleExecutor<PostBean>, org.springframework.data.repository.Repository<PostBean,​java.lang.Integer>

public interface PostsRepository
extends org.springframework.data.jpa.repository.JpaRepository<PostBean,​java.lang.Integer>
Spring Data Repository for easy use of CRUD operations on the PostBean object
  • Method Summary

    Modifier and Type Method Description
    java.util.List<PostBean> findAllByCampaignId​(int campaignId)
    Returns a list of posts by the creator
    PostBean findPostBeanByUrl​(java.lang.String url)
    returns a post by the post's link
    java.util.List<java.lang.Object[]> findPostsInListByListId​(int list_id, java.lang.String url)
    find the posts in a list by list_id
    java.util.List<PostBean> getExistingPosts​(java.util.List<PostBean> pbList)
    getExistingPosts() checks what posts in the PostBean object list are already in the database
    org.springframework.data.domain.Page<PostBean> getMultipleCreatorPosts​(java.util.List<java.lang.String> campaignList, org.springframework.data.domain.Pageable pageable)
    Returns the posts from multiple creators in paginated json body

    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, findAll, findAll, findAllById, flush, getById, getOne, getReferenceById, saveAll, saveAllAndFlush, saveAndFlush

    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

    • getMultipleCreatorPosts

      @Query(value="SELECT * FROM posts WHERE campaign_id in ?1", countQuery="SELECT count(*) FROM posts WHERE campaign_id in ?1", nativeQuery=true) org.springframework.data.domain.Page<PostBean> getMultipleCreatorPosts​(java.util.List<java.lang.String> campaignList, org.springframework.data.domain.Pageable pageable)
      Returns the posts from multiple creators in paginated json body
      Parameters:
      campaignList - is the list of creators we want to get posts from
      pageable - is the Pageable object we use to paginate our data
      Returns:
      is the Page object with our json body data holding posts from specified creators
    • findAllByCampaignId

      java.util.List<PostBean> findAllByCampaignId​(int campaignId)
      Returns a list of posts by the creator
      Parameters:
      campaignId - is the creator's unique name
      Returns:
      a list of PostBean objects
    • findPostBeanByUrl

      PostBean findPostBeanByUrl​(java.lang.String url)
      returns a post by the post's link
      Parameters:
      url - is the url of the post we want to find
      Returns:
      a PostBean object
    • getExistingPosts

      java.util.List<PostBean> getExistingPosts​(java.util.List<PostBean> pbList)
      getExistingPosts() checks what posts in the PostBean object list are already in the database
      Parameters:
      pbList - is the list of PostBean objects that we want to check the database for
      Returns:
      a list of PostBean objects that were shown to be in the database
    • findPostsInListByListId

      @Query(value="SELECT * FROM list_posts RIGHT JOIN posts ON list_posts.post_id = posts.post_id where list_id = ?1", nativeQuery=true) java.util.List<java.lang.Object[]> findPostsInListByListId​(int list_id, java.lang.String url)
      find the posts in a list by list_id
      Parameters:
      list_id - is the id of a list
      Returns:
      a list of PostBean