diff --git a/src/main/java/com/loafle/overflow/module/infra/dao/InfraDAO.java b/src/main/java/com/loafle/overflow/module/infra/dao/InfraDAO.java index dec00ed..e124b32 100644 --- a/src/main/java/com/loafle/overflow/module/infra/dao/InfraDAO.java +++ b/src/main/java/com/loafle/overflow/module/infra/dao/InfraDAO.java @@ -1,14 +1,18 @@ package com.loafle.overflow.module.infra.dao; +import com.loafle.overflow.module.domain.model.Domain; import com.loafle.overflow.module.infra.model.Infra; +import com.loafle.overflow.module.probe.model.Probe; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + /** * Created by insanity on 17. 6. 23. */ @Repository public interface InfraDAO extends JpaRepository { -// @Query("select m from Member m WHERE m.email = :#{#m2.email}") -// Member findByEmail(@Param("m2") Member member); + public List findAllByProbe(Probe probe); + } \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java b/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java index f154a99..e37a092 100644 --- a/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java +++ b/src/main/java/com/loafle/overflow/module/infra/service/InfraService.java @@ -1,10 +1,14 @@ package com.loafle.overflow.module.infra.service; +import com.loafle.overflow.module.domain.model.Domain; import com.loafle.overflow.module.infra.dao.InfraDAO; import com.loafle.overflow.module.infra.model.Infra; +import com.loafle.overflow.module.probe.model.Probe; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** * Created by insanity on 17. 6. 28. */ @@ -23,4 +27,8 @@ public class InfraService { return this.infraDAO.findOne(id); } + public List readAllByProbe(Probe probe) { + return this.infraDAO.findAllByProbe(probe); + } + } diff --git a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java index 64dd970..7d39cfb 100644 --- a/src/main/java/com/loafle/overflow/module/member/service/MemberService.java +++ b/src/main/java/com/loafle/overflow/module/member/service/MemberService.java @@ -2,6 +2,7 @@ package com.loafle.overflow.module.member.service; import com.loafle.overflow.module.member.dao.MemberDAO; import com.loafle.overflow.module.member.model.Member; +import com.loafle.overflow.module.meta.model.MetaMemberStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; @@ -37,6 +38,10 @@ public class MemberService { BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); member.setPw(passwordEncoder.encode(member.getPw())); + + if (member.getStatus() == null) { + member.setStatus(new MetaMemberStatus((short) 1)); + } return this.memberDAO.save(member); } diff --git a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java index 7067b6a..6246da6 100644 --- a/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java +++ b/src/main/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeService.java @@ -32,4 +32,8 @@ public class NoAuthProbeService { return this.noAuthProbeDAO.findOne(id); } + public List registForNoAuthProbes(List noAuthProbes) { + + return this.noAuthProbeDAO.save(noAuthProbes); + } } diff --git a/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java b/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java index 3b78f8a..1aca277 100644 --- a/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java +++ b/src/main/java/com/loafle/overflow/module/probe/service/ProbeService.java @@ -26,6 +26,10 @@ public class ProbeService { return this.probeDAO.findAllByDomain(domain); } + public Probe read(long id) { + return this.probeDAO.findOne(id); + } + public Probe readByProbeKey(String probeKey) { return this.probeDAO.findByProbeKey(probeKey); diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index 79af34b..f795b03 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -400,6 +400,12 @@ INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( INSERT INTO public.noauth_probe (api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES ( '52abd6fd57e511e7ac52080027658d13','2017-06-26 12:43:46.877','snoop',3232235980,8796753988883,'1cf2555c57d511e79714080027658d13',1,NULL,3); +INSERT INTO public.noauth_probe (api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES ( +'52abd6fd57e511e7ac52080027658d14','2017-08-11 12:43:46.877','geek',3232235980,8796753988883,'1cf2555c57d511e79714080027658d14',1,NULL,3); + +INSERT INTO public.noauth_probe (api_key,create_date,host_name,ip_address,mac_address,temp_probe_key,domain_id,probe_id,status) VALUES ( +'52abd6fd57e511e7ac52080027658d15','2017-08-11 12:43:46.877','insanity',3232235980,8796753988883,'1cf2555c57d511e79714080027658d15',1,NULL,3); + INSERT INTO public.infra_machine (create_date,meta) VALUES ( '2017-07-27 19:54:26.677',''); diff --git a/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java b/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java index 9e8e134..e2e653d 100644 --- a/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java @@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.util.ArrayList; import java.util.List; import static org.junit.Assert.*; @@ -54,6 +55,38 @@ public class NoAuthProbeServiceTest { } + @Ignore + @Test + public void registForNoAuthProbes() throws Exception { + + NoAuthProbe noAuthProbe = new NoAuthProbe(); + + noAuthProbe.setHostName("geek"); + noAuthProbe.setIpAddress(3232235980L); + noAuthProbe.setMacAddress(8796753988883L); + noAuthProbe.setApiKey("521abd6fd57e511e7ac52080027658d13"); + + MetaNoAuthProbeStatus metaNoAuthProbeStatus = new MetaNoAuthProbeStatus(); + metaNoAuthProbeStatus.setId((short)3); + + noAuthProbe.setStatus(metaNoAuthProbeStatus); + noAuthProbe.setTempProbeKey("a1c7f252b5bc811e784ad080027658d13"); + + Domain d = new Domain(); + d.setId(1); + noAuthProbe.setDomain(d); + + List noAuthProbes = new ArrayList(); + + noAuthProbes.add(noAuthProbe); + List dd = this.noAuthProbeService.registForNoAuthProbes(noAuthProbes); + +// System.out.println(dd.get(0).getId()); + + Assert.assertNotEquals(noAuthProbes.size(), 2); + + } + @Ignore @Test public void readAllByDomain() throws Exception { diff --git a/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java b/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java index f0a2eac..7397ef4 100644 --- a/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/probe/service/ProbeServiceTest.java @@ -77,7 +77,7 @@ public class ProbeServiceTest { List probes = this.probeService.readAllByDomain(domain); - Assert.assertNotEquals(probes.size(), 0); + Assert.assertEquals(probes.size(), 1); }