Package com.jangular.backend.repository

# Interface UserLoginHistoryRepository

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

@Repository public interface UserLoginHistoryRepository extends org.springframework.data.jpa.repository.JpaRepository<UserLoginHistory,Long>

## Method Summary

Modifier and Type
Method
Description
`List<UserLoginHistory>`
`findActiveSessionsByUserId(Long userId)`
`List<UserLoginHistory>`
`findByUserIdAndLoginTimeBetween(Long userId, LocalDateTime startDate, LocalDateTime endDate)`
`List<UserLoginHistory>`
`findByUserIdAndSuccessfulOrderByLoginTimeDesc(Long userId, boolean successful)`
`List<UserLoginHistory>`
`findByUserIdOrderByLoginTimeDesc(Long userId)`
`Optional<UserLoginHistory>`
`findTopByUserIdAndSuccessfulTrueAndLogoutTimeIsNullOrderByLoginTimeDesc(Long userId)`

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

### findByUserIdOrderByLoginTimeDesc

List<UserLoginHistory> findByUserIdOrderByLoginTimeDesc(Long userId)

### findByUserIdAndSuccessfulOrderByLoginTimeDesc

List<UserLoginHistory> findByUserIdAndSuccessfulOrderByLoginTimeDesc(Long userId, boolean successful)

### findActiveSessionsByUserId

@Query("SELECT h FROM UserLoginHistory h WHERE h.userId = :userId AND h.logoutTime IS NULL ORDER BY h.loginTime DESC") List<UserLoginHistory> findActiveSessionsByUserId(@Param("userId") Long userId)

### findByUserIdAndLoginTimeBetween

@Query("SELECT h FROM UserLoginHistory h WHERE h.userId = :userId AND h.loginTime >= :startDate AND h.loginTime <= :endDate") List<UserLoginHistory> findByUserIdAndLoginTimeBetween(@Param("userId") Long userId, @Param("startDate") LocalDateTime startDate, @Param("endDate") LocalDateTime endDate)

### findTopByUserIdAndSuccessfulTrueAndLogoutTimeIsNullOrderByLoginTimeDesc

Optional<UserLoginHistory> findTopByUserIdAndSuccessfulTrueAndLogoutTimeIsNullOrderByLoginTimeDesc(Long userId)