Interface UserRecentCityViewRepository

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

@Repository public interface UserRecentCityViewRepository extends org.springframework.data.jpa.repository.JpaRepository<UserRecentCityView,UserRecentCityView.Key>
Repository for UserRecentCityView entities.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addCityView(UUID userId, UUID cityId)
    Adds a new city view for a user.
    Counts the number of user recent city views created between two timestamps.
    void
    Deletes all recent city views for a user.
    findByUserIdAndCityId(UUID userId, UUID cityId)
    Finds a user's recent city view by user ID and city ID.
    getByUserIdOrderByUpdatedAtDesc(UUID userId, org.springframework.data.domain.Pageable pageable)
    Gets a list of a user's recent city views, ordered by last updated time.

    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.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

    • getByUserIdOrderByUpdatedAtDesc

      @Async CompletableFuture<List<UserRecentCityView>> getByUserIdOrderByUpdatedAtDesc(UUID userId, org.springframework.data.domain.Pageable pageable)
      Gets a list of a user's recent city views, ordered by last updated time.
      Parameters:
      userId - The ID of the user.
      pageable - The pageable request.
      Returns:
      A completable future containing a list of user recent city views.
    • findByUserIdAndCityId

      Optional<UserRecentCityView> findByUserIdAndCityId(UUID userId, UUID cityId)
      Finds a user's recent city view by user ID and city ID.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
      Returns:
      An optional containing the user recent city view if found, otherwise empty.
    • deleteAllByUserId

      void deleteAllByUserId(UUID userId)
      Deletes all recent city views for a user.
      Parameters:
      userId - The ID of the user.
    • addCityView

      @Modifying @Transactional @Query(value="insert into user_recent_city_views (user_id, city_id, created_at, updated_at) values (:userId, :cityId, current_timestamp, current_timestamp) on conflict do nothing", nativeQuery=true) void addCityView(UUID userId, UUID cityId)
      Adds a new city view for a user.
      Parameters:
      userId - The ID of the user.
      cityId - The ID of the city.
    • countByCreatedAtBetween

      @Async CompletableFuture<Long> countByCreatedAtBetween(Instant start, Instant end)
      Counts the number of user recent city views created between two timestamps.
      Parameters:
      start - The start timestamp.
      end - The end timestamp.
      Returns:
      A completable future containing the number of views.