This commit is contained in:
insanity 2018-04-25 16:18:28 +09:00
parent 8693503077
commit 7024141849
2 changed files with 21 additions and 0 deletions

View File

@ -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, Long> {
ProbeHost findByProbe(Probe probe);
@Query("SELECT h FROM ProbeHost h WHERE h.probe.domain = (:domain)")
List<ProbeHost> findAllByDomain(@Param("domain")Domain domain);
}

View File

@ -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<ProbeHost> readAllByDomain(Domain domain) throws OverflowException {
return this.probeHostDAO.findAllByDomain(domain);
}
}