Interface UserRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<User,,UUID> org.springframework.data.jpa.repository.JpaRepository<User,,UUID> org.springframework.data.repository.ListCrudRepository<User,,UUID> org.springframework.data.repository.ListPagingAndSortingRepository<User,,UUID> org.springframework.data.repository.PagingAndSortingRepository<User,,UUID> org.springframework.data.repository.query.QueryByExampleExecutor<User>,org.springframework.data.repository.Repository<User,UUID>
-
Method Summary
Modifier and TypeMethodDescriptionFind a user by their unique user IDFind all online usersfindRecentlyActiveUsers(Instant since) Find recently active users (online or last seen within specified time)voidupdateOnlineStatus(UUID userId, boolean online, Instant lastSeen) Update user online statusMethods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, 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.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
-
findById
Find a user by their unique user ID -
findByOnlineTrue
Find all online users -
updateOnlineStatus
@Modifying @Query("UPDATE User u SET u.online = :online, u.lastSeen = :lastSeen WHERE u.id = :userId") void updateOnlineStatus(@Param("userId") UUID userId, @Param("online") boolean online, @Param("lastSeen") Instant lastSeen) Update user online status -
findRecentlyActiveUsers
@Query("SELECT u FROM User u WHERE u.online = true OR u.lastSeen >= :since ORDER BY u.lastSeen DESC") List<User> findRecentlyActiveUsers(@Param("since") Instant since) Find recently active users (online or last seen within specified time)
-