Package com.bytedesk.core.relation
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>
-
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 TypeMethodDescriptioncountFavoritesByContentId(String contentId) 统计内容收藏数量countFollowersByUserId(String userId) 统计用户粉丝数量countFollowingsByUserId(String userId) 统计用户关注数量countLikesByContentId(String contentId) 统计内容点赞数量existsByUid(String uid) existsRelationBetweenUsers(String subjectUserId, String objectUserId, String type) 检查两个用户之间是否存在特定类型的关系findByObjectContentUidAndTypeAndDeletedFalse(String objectContentUid, String type) 根据客体内容ID和关系类型查询关系findByObjectUserUidAndTypeAndDeletedFalse(String objectUserUid, String type) 根据客体用户ID和关系类型查询关系findBySubjectUserUidAndTypeAndDeletedFalse(String subjectUserUid, String type) 根据主体用户ID和关系类型查询关系findFavoritesByContentId(String contentId) 查询内容被收藏的关系findFavoritesByUserId(String userId) 查询用户收藏的内容org.springframework.data.domain.Page<RelationEntity>findFavoritesByUserIdPageable(String userId, org.springframework.data.domain.Pageable pageable) 分页查询用户收藏的内容findFollowersByUserId(String userId) 查询关注用户的粉丝org.springframework.data.domain.Page<RelationEntity>findFollowersByUserIdPageable(String userId, org.springframework.data.domain.Pageable pageable) 分页查询关注用户的粉丝findFollowingsByUserId(String userId) 查询用户关注的其他用户org.springframework.data.domain.Page<RelationEntity>findFollowingsByUserIdPageable(String userId, org.springframework.data.domain.Pageable pageable) 分页查询用户关注的其他用户findFriendsByUserId(String userId) 查询互相关注的好友findLikesByContentId(String contentId) 查询内容被点赞的关系findLikesByUserId(String userId) 查询用户点赞的内容org.springframework.data.domain.Page<RelationEntity>findLikesByUserIdPageable(String userId, org.springframework.data.domain.Pageable pageable) 分页查询用户点赞的内容hasFavorited(String userId, String contentId) 检查用户是否收藏了某个内容检查用户是否点赞了某个内容isFollowing(String subjectUserId, String objectUserId) 检查用户是否关注了另一个用户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
-
findByUid
-
existsByUid
-
findBySubjectUserUidAndTypeAndDeletedFalse
根据主体用户ID和关系类型查询关系 -
findByObjectUserUidAndTypeAndDeletedFalse
根据客体用户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) 统计内容收藏数量
-