Package com.bytedesk.core.ip_access
Interface IpAccessRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<IpAccessEntity,
,Long> org.springframework.data.jpa.repository.JpaRepository<IpAccessEntity,
,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<IpAccessEntity>
,org.springframework.data.repository.ListCrudRepository<IpAccessEntity,
,Long> org.springframework.data.repository.ListPagingAndSortingRepository<IpAccessEntity,
,Long> org.springframework.data.repository.PagingAndSortingRepository<IpAccessEntity,
,Long> org.springframework.data.repository.query.QueryByExampleExecutor<IpAccessEntity>
,org.springframework.data.repository.Repository<IpAccessEntity,
Long>
public interface IpAccessRepository
extends org.springframework.data.jpa.repository.JpaRepository<IpAccessEntity,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<IpAccessEntity>
-
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 TypeMethodDescriptionlong
countByIpAndEndpointAndAccessTimeAfter
(String ip, String endpoint, ZonedDateTime time) 统计指定IP在指定时间范围内的访问次数existsByUid
(String uid) findByIpsAndEndpointAndAccessTimeAfter
(List<String> ips, String endpoint, ZonedDateTime time) 批量查询IP访问记录 用于批量检查多个IP的访问情况findFirstByIpAndEndpointAndAccessTimeAfter
(String ip, String endpoint, ZonedDateTime time) findFirstByIpAndEndpointAndHttpMethodAndAccessTimeAfter
(String ip, String endpoint, String httpMethod, ZonedDateTime time) int
incrementAccessCount
(Long id, ZonedDateTime lastAccessTime, ZonedDateTime updatedAt) 原子更新访问次数和最后访问时间 使用原生SQL避免乐观锁冲突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.jpa.repository.JpaSpecificationExecutor
count, delete, exists, findAll, findAll, findAll, findAll, findBy, findOne
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
-
findFirstByIpAndEndpointAndAccessTimeAfter
Optional<IpAccessEntity> findFirstByIpAndEndpointAndAccessTimeAfter(String ip, String endpoint, ZonedDateTime time) -
findFirstByIpAndEndpointAndHttpMethodAndAccessTimeAfter
Optional<IpAccessEntity> findFirstByIpAndEndpointAndHttpMethodAndAccessTimeAfter(String ip, String endpoint, String httpMethod, ZonedDateTime time) -
findByUid
-
existsByUid
-
incrementAccessCount
@Modifying @Transactional @Query(value="UPDATE bytedesk_core_ip_access SET access_count = access_count + 1, last_access_time = :lastAccessTime, updated_at = :updatedAt WHERE id = :id", nativeQuery=true) int incrementAccessCount(@Param("id") Long id, @Param("lastAccessTime") ZonedDateTime lastAccessTime, @Param("updatedAt") ZonedDateTime updatedAt) 原子更新访问次数和最后访问时间 使用原生SQL避免乐观锁冲突 -
findByIpsAndEndpointAndAccessTimeAfter
@Query("SELECT a FROM IpAccessEntity a WHERE a.ip IN :ips AND a.endpoint = :endpoint AND a.accessTime > :time") List<IpAccessEntity> findByIpsAndEndpointAndAccessTimeAfter(@Param("ips") List<String> ips, @Param("endpoint") String endpoint, @Param("time") ZonedDateTime time) 批量查询IP访问记录 用于批量检查多个IP的访问情况 -
countByIpAndEndpointAndAccessTimeAfter
@Query("SELECT COUNT(a) FROM IpAccessEntity a WHERE a.ip = :ip AND a.endpoint = :endpoint AND a.accessTime > :time") long countByIpAndEndpointAndAccessTimeAfter(@Param("ip") String ip, @Param("endpoint") String endpoint, @Param("time") ZonedDateTime time) 统计指定IP在指定时间范围内的访问次数
-