diff --git a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java index 52cd495..4e8bd2c 100644 --- a/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java +++ b/src/main/java/com/loafle/overflow/central/module/probe/dao/ProbeHostDAO.java @@ -1,15 +1,24 @@ package com.loafle.overflow.central.module.probe.dao; +import java.util.List; + +import com.loafle.overflow.model.domain.Domain; import com.loafle.overflow.model.probe.Probe; import com.loafle.overflow.model.probe.ProbeHost; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; + /** * Created by snoop on 17. 8. 21. */ @Repository public interface ProbeHostDAO extends JpaRepository { ProbeHost findByProbe(Probe probe); + + @Query("SELECT h FROM ProbeHost h WHERE h.probe.domain = (:domain)") + List findAllByDomain(@Param("domain")Domain domain); } diff --git a/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeHostService.java b/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeHostService.java index 0e468e4..91959a5 100644 --- a/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeHostService.java +++ b/src/main/java/com/loafle/overflow/central/module/probe/service/CentralProbeHostService.java @@ -1,7 +1,10 @@ package com.loafle.overflow.central.module.probe.service; +import java.util.List; + import com.loafle.overflow.central.module.probe.dao.ProbeHostDAO; import com.loafle.overflow.core.exception.OverflowException; +import com.loafle.overflow.model.domain.Domain; import com.loafle.overflow.model.probe.Probe; import com.loafle.overflow.model.probe.ProbeHost; import com.loafle.overflow.service.central.probe.ProbeHostService; @@ -18,6 +21,10 @@ public class CentralProbeHostService implements ProbeHostService { @Autowired private ProbeHostDAO probeHostDAO; + public ProbeHost read(long id) throws OverflowException { + return this.probeHostDAO.findOne(id); + } + public ProbeHost readByProbe(Probe probe) throws OverflowException { return this.probeHostDAO.findByProbe(probe); } @@ -25,4 +32,9 @@ public class CentralProbeHostService implements ProbeHostService { public ProbeHost regist(ProbeHost probeHost) throws OverflowException { return this.probeHostDAO.save(probeHost); } + + public List readAllByDomain(Domain domain) throws OverflowException { + return this.probeHostDAO.findAllByDomain(domain); + } } +