Interface RelationRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<RelationEntity,Long>, org.springframework.data.jpa.repository.JpaRepository<RelationEntity,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<RelationEntity>, org.springframework.data.repository.ListCrudRepository<RelationEntity,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<RelationEntity,Long>, org.springframework.data.repository.PagingAndSortingRepository<RelationEntity,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<RelationEntity>, org.springframework.data.repository.Repository<RelationEntity,Long>

public interface RelationRepository extends org.springframework.data.jpa.repository.JpaRepository<RelationEntity,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<RelationEntity>
  • Method Details

    • findByUid

      Optional<RelationEntity> findByUid(String uid)
    • existsByUid

      Boolean existsByUid(String uid)
    • findBySubjectUserUidAndTypeAndDeletedFalse

      List<RelationEntity> findBySubjectUserUidAndTypeAndDeletedFalse(String subjectUserUid, String type)
      根据主体用户ID和关系类型查询关系
    • findByObjectUserUidAndTypeAndDeletedFalse

      List<RelationEntity> findByObjectUserUidAndTypeAndDeletedFalse(String objectUserUid, String type)
      根据客体用户ID和关系类型查询关系
    • findByObjectContentUidAndTypeAndDeletedFalse

      List<RelationEntity> findByObjectContentUidAndTypeAndDeletedFalse(String objectContentUid, String type)
      根据客体内容ID和关系类型查询关系
    • findFollowingsByUserId

      @Query("SELECT r FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.type = \'FOLLOW\' AND r.deleted = false") List<RelationEntity> findFollowingsByUserId(@Param("userId") String userId)
      查询用户关注的其他用户
    • findFollowersByUserId

      @Query("SELECT r FROM RelationEntity r WHERE r.objectUserUid = :userId AND r.type = \'FOLLOW\' AND r.deleted = false") List<RelationEntity> findFollowersByUserId(@Param("userId") String userId)
      查询关注用户的粉丝
    • findFriendsByUserId

      @Query("SELECT r FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.type = \'FRIEND\' AND r.deleted = false") List<RelationEntity> findFriendsByUserId(@Param("userId") String userId)
      查询互相关注的好友
    • findLikesByUserId

      @Query("SELECT r FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.type = \'LIKE\' AND r.deleted = false") List<RelationEntity> findLikesByUserId(@Param("userId") String userId)
      查询用户点赞的内容
    • findFavoritesByUserId

      @Query("SELECT r FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.type = \'FAVORITE\' AND r.deleted = false") List<RelationEntity> findFavoritesByUserId(@Param("userId") String userId)
      查询用户收藏的内容
    • findLikesByContentId

      @Query("SELECT r FROM RelationEntity r WHERE r.objectContentUid = :contentId AND r.type = \'LIKE\' AND r.deleted = false") List<RelationEntity> findLikesByContentId(@Param("contentId") String contentId)
      查询内容被点赞的关系
    • findFavoritesByContentId

      @Query("SELECT r FROM RelationEntity r WHERE r.objectContentUid = :contentId AND r.type = \'FAVORITE\' AND r.deleted = false") List<RelationEntity> findFavoritesByContentId(@Param("contentId") String contentId)
      查询内容被收藏的关系
    • existsRelationBetweenUsers

      @Query("SELECT COUNT(r) > 0 FROM RelationEntity r WHERE r.subjectUserUid = :subjectUserId AND r.objectUserUid = :objectUserId AND r.type = :type AND r.deleted = false") Boolean existsRelationBetweenUsers(@Param("subjectUserId") String subjectUserId, @Param("objectUserId") String objectUserId, @Param("type") String type)
      检查两个用户之间是否存在特定类型的关系
    • isFollowing

      @Query("SELECT COUNT(r) > 0 FROM RelationEntity r WHERE r.subjectUserUid = :subjectUserId AND r.objectUserUid = :objectUserId AND r.type = \'FOLLOW\' AND r.deleted = false") Boolean isFollowing(@Param("subjectUserId") String subjectUserId, @Param("objectUserId") String objectUserId)
      检查用户是否关注了另一个用户
    • hasLiked

      @Query("SELECT COUNT(r) > 0 FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.objectContentUid = :contentId AND r.type = \'LIKE\' AND r.deleted = false") Boolean hasLiked(@Param("userId") String userId, @Param("contentId") String contentId)
      检查用户是否点赞了某个内容
    • hasFavorited

      @Query("SELECT COUNT(r) > 0 FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.objectContentUid = :contentId AND r.type = \'FAVORITE\' AND r.deleted = false") Boolean hasFavorited(@Param("userId") String userId, @Param("contentId") String contentId)
      检查用户是否收藏了某个内容
    • findFollowingsByUserIdPageable

      @Query("SELECT r FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.type = \'FOLLOW\' AND r.deleted = false") org.springframework.data.domain.Page<RelationEntity> findFollowingsByUserIdPageable(@Param("userId") String userId, org.springframework.data.domain.Pageable pageable)
      分页查询用户关注的其他用户
    • findFollowersByUserIdPageable

      @Query("SELECT r FROM RelationEntity r WHERE r.objectUserUid = :userId AND r.type = \'FOLLOW\' AND r.deleted = false") org.springframework.data.domain.Page<RelationEntity> findFollowersByUserIdPageable(@Param("userId") String userId, org.springframework.data.domain.Pageable pageable)
      分页查询关注用户的粉丝
    • findLikesByUserIdPageable

      @Query("SELECT r FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.type = \'LIKE\' AND r.deleted = false") org.springframework.data.domain.Page<RelationEntity> findLikesByUserIdPageable(@Param("userId") String userId, org.springframework.data.domain.Pageable pageable)
      分页查询用户点赞的内容
    • findFavoritesByUserIdPageable

      @Query("SELECT r FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.type = \'FAVORITE\' AND r.deleted = false") org.springframework.data.domain.Page<RelationEntity> findFavoritesByUserIdPageable(@Param("userId") String userId, org.springframework.data.domain.Pageable pageable)
      分页查询用户收藏的内容
    • countFollowingsByUserId

      @Query("SELECT COUNT(r) FROM RelationEntity r WHERE r.subjectUserUid = :userId AND r.type = \'FOLLOW\' AND r.deleted = false") Long countFollowingsByUserId(@Param("userId") String userId)
      统计用户关注数量
    • countFollowersByUserId

      @Query("SELECT COUNT(r) FROM RelationEntity r WHERE r.objectUserUid = :userId AND r.type = \'FOLLOW\' AND r.deleted = false") Long countFollowersByUserId(@Param("userId") String userId)
      统计用户粉丝数量
    • countLikesByContentId

      @Query("SELECT COUNT(r) FROM RelationEntity r WHERE r.objectContentUid = :contentId AND r.type = \'LIKE\' AND r.deleted = false") Long countLikesByContentId(@Param("contentId") String contentId)
      统计内容点赞数量
    • countFavoritesByContentId

      @Query("SELECT COUNT(r) FROM RelationEntity r WHERE r.objectContentUid = :contentId AND r.type = \'FAVORITE\' AND r.deleted = false") Long countFavoritesByContentId(@Param("contentId") String contentId)
      统计内容收藏数量