email token duplication check

This commit is contained in:
geek 2018-06-06 19:37:09 +09:00
parent e47e0cdf65
commit a696eb1d27
3 changed files with 68 additions and 36 deletions

View File

@ -1,13 +1,24 @@
package com.loafle.overflow.central.module.target.dao; package com.loafle.overflow.central.module.target.dao;
import com.loafle.overflow.model.target.Target; import com.loafle.overflow.model.target.Target;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; 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; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* Created by root on 17. 6. 5. * Created by root on 17. 6. 5.
*/ */
@Repository @Repository
public interface TargetDAO extends JpaRepository<Target, Long> { public interface TargetDAO extends JpaRepository<Target, Long> {
Target findByInfraId(Long infraId); Target findByInfraId(Long infraId);
// @Query("select t.infra from target t where t.infra.probe.id = :probeId")
// Page<Target> findForProbeId(@Param("probeId") Long probeId, Pageable pageRequest);
Page<Target> findAllByInfraProbeId(Long probeId, Pageable pageRequest);
} }

View File

@ -3,6 +3,7 @@ package com.loafle.overflow.central.module.target.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.loafle.overflow.central.commons.utils.PageUtil;
import com.loafle.overflow.central.module.infra.service.CentralInfraHostService; import com.loafle.overflow.central.module.infra.service.CentralInfraHostService;
import com.loafle.overflow.central.module.infra.service.CentralInfraServiceService; import com.loafle.overflow.central.module.infra.service.CentralInfraServiceService;
import com.loafle.overflow.central.module.probe.service.CentralProbeService; import com.loafle.overflow.central.module.probe.service.CentralProbeService;
@ -100,7 +101,8 @@ public class CentralTargetService implements TargetService {
} }
public Page<Target> readAllByProbeID(Long probeID, PageParams pageParams) throws OverflowException { public Page<Target> readAllByProbeID(Long probeID, PageParams pageParams) throws OverflowException {
return null; return this.targetDAO.findAllByInfraProbeId(probeID, PageUtil.getPageRequest(pageParams));
// return null;
} }
@Transactional @Transactional
public List<Target> registDiscoveredTargets(Long probeId, List<Host> hosts, List<Service> services) public List<Target> registDiscoveredTargets(Long probeId, List<Host> hosts, List<Service> services)

View File

@ -1,48 +1,67 @@
// package com.loafle.overflow.central.module.target.service; package com.loafle.overflow.central.module.target.service;
// import com.loafle.overflow.central.module.target.model.Target;
// import com.loafle.overflow.central.spring.AppConfigTest;
// import org.junit.Assert;
// import org.junit.Ignore;
// import org.junit.Test;
// import org.junit.runner.RunWith;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.test.context.ContextConfiguration;
// import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
// import java.util.Date; import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.service.central.target.TargetService;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
// /** import java.util.Date;
// * Created by insanity on 17. 6. 28.
// */
// @RunWith(SpringJUnit4ClassRunner.class) /**
// @ContextConfiguration(classes = {AppConfigTest.class}) * Created by insanity on 17. 6. 28.
// public class TargetServiceTest { */
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("test")
@ContextConfiguration(classes = {AppConfigTest.class})
public class TargetServiceTest {
// @Autowired // @Autowired
// TargetService targetService; // TargetService targetService;
//
// @Ignore // @Ignore
// @Test // @Test
// public void regist() throws Exception { // public void regist() throws Exception {
// Target t = new Target(); //// Target t = new Target();
// t.setCreateDate(new Date()); //// t.setCreateDate(new Date());
// // Infra infra = new Infra(); //// // Infra infra = new Infra();
// // infra.setId(1); //// // infra.setId(1);
// // Probe probe = new Probe(); //// // Probe probe = new Probe();
// // probe.setId(1); //// // probe.setId(1);
// // t.setProbe(probe); //// // t.setProbe(probe);
// // t.setInfra(infra); //// // t.setInfra(infra);
// t.setDescription("i am target"); //// t.setDescription("i am target");
// t.setDisplayName("ghost target"); //// t.setDisplayName("ghost target");
////
// Target res = this.targetService.regist(t); //// Target res = this.targetService.regist(t);
// Assert.assertNotNull(res); //// Assert.assertNotNull(res);
// } // }
//
// @Test // @Test
// @Ignore
// public void read() throws Exception { // public void read() throws Exception {
// Target res = this.targetService.read("1"); //// Target res = this.targetService.read("1");
// Assert.assertNotNull(res); //// Assert.assertNotNull(res);
// } // }
// } //
// @Test
// public void testReadAllByProbeId() throws Exception {
// PageParams pageParams = new PageParams();
// pageParams.setPageNo(1);
// pageParams.setCountPerPage(10);
//
// Page<Target> targets = this.targetService.readAllByProbeID((long)1, pageParams);
//
// System.out.println(targets.getSize());
// }
//
}