package cn.lihongjie.coal.ipList.repository;

import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.ipList.entity.IpListEntity;

import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;

@Repository
public interface IpListRepository extends BaseRepository<IpListEntity> {
    @Query(value = "select address_type from t_ip_list where address >>= cast(?1 as inet) and start_time <=?2 and end_time>=?2 order by address_type desc limit 1 ", nativeQuery = true)
    String getAddressType(String address, LocalDateTime now);
}
