package com.jsc.oscm.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.jsc.oscm.entity.CrawlNode;

public interface CrawlNodeRepository extends JpaRepository<CrawlNode, Integer> {
    /*
     * add by pangq 2021/2/5
     * 增加通过hostid删除节点的接口
     */
    @Transactional
    @Modifying
    @Query(value = "delete from crawl_node where host_id in ?1", nativeQuery = true)
    void deleteNodesByHostId(List<Integer> ids);

    @Query(value = "SELECT id FROM crawl_node WHERE node_ip = ?1", nativeQuery = true)
    String queryNodeIdByIpPort(String IpPort);
    
    @Query(value = "SELECT * FROM crawl_node WHERE node_ip in (?1)", nativeQuery = true)
    List<CrawlNode> queryNodesByIpPort(String[] IpPort);
}
