Merge remote-tracking branch 'origin/master'

This commit is contained in:
snoop 2017-08-11 18:09:41 +09:00
commit cd512a38a4
8 changed files with 67 additions and 3 deletions

View File

@ -1,14 +1,18 @@
package com.loafle.overflow.module.infra.dao; 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.infra.model.Infra;
import com.loafle.overflow.module.probe.model.Probe;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* Created by insanity on 17. 6. 23. * Created by insanity on 17. 6. 23.
*/ */
@Repository @Repository
public interface InfraDAO extends JpaRepository<Infra, Long> { public interface InfraDAO extends JpaRepository<Infra, Long> {
// @Query("select m from Member m WHERE m.email = :#{#m2.email}") public List<Infra> findAllByProbe(Probe probe);
// Member findByEmail(@Param("m2") Member member);
} }

View File

@ -1,10 +1,14 @@
package com.loafle.overflow.module.infra.service; 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.dao.InfraDAO;
import com.loafle.overflow.module.infra.model.Infra; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* Created by insanity on 17. 6. 28. * Created by insanity on 17. 6. 28.
*/ */
@ -23,4 +27,8 @@ public class InfraService {
return this.infraDAO.findOne(id); return this.infraDAO.findOne(id);
} }
public List<Infra> readAllByProbe(Probe probe) {
return this.infraDAO.findAllByProbe(probe);
}
} }

View File

@ -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.dao.MemberDAO;
import com.loafle.overflow.module.member.model.Member; 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.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -37,6 +38,10 @@ public class MemberService {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
member.setPw(passwordEncoder.encode(member.getPw())); member.setPw(passwordEncoder.encode(member.getPw()));
if (member.getStatus() == null) {
member.setStatus(new MetaMemberStatus((short) 1));
}
return this.memberDAO.save(member); return this.memberDAO.save(member);
} }

View File

@ -32,4 +32,8 @@ public class NoAuthProbeService {
return this.noAuthProbeDAO.findOne(id); return this.noAuthProbeDAO.findOne(id);
} }
public List<NoAuthProbe> registForNoAuthProbes(List<NoAuthProbe> noAuthProbes) {
return this.noAuthProbeDAO.save(noAuthProbes);
}
} }

View File

@ -26,6 +26,10 @@ public class ProbeService {
return this.probeDAO.findAllByDomain(domain); return this.probeDAO.findAllByDomain(domain);
} }
public Probe read(long id) {
return this.probeDAO.findOne(id);
}
public Probe readByProbeKey(String probeKey) { public Probe readByProbeKey(String probeKey) {
return this.probeDAO.findByProbeKey(probeKey); return this.probeDAO.findByProbeKey(probeKey);

View File

@ -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 ( 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); '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 ( INSERT INTO public.infra_machine (create_date,meta) VALUES (
'2017-07-27 19:54:26.677',''); '2017-07-27 19:54:26.677','');

View File

@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static org.junit.Assert.*; 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<NoAuthProbe> noAuthProbes = new ArrayList<NoAuthProbe>();
noAuthProbes.add(noAuthProbe);
List<NoAuthProbe> dd = this.noAuthProbeService.registForNoAuthProbes(noAuthProbes);
// System.out.println(dd.get(0).getId());
Assert.assertNotEquals(noAuthProbes.size(), 2);
}
@Ignore @Ignore
@Test @Test
public void readAllByDomain() throws Exception { public void readAllByDomain() throws Exception {

View File

@ -77,7 +77,7 @@ public class ProbeServiceTest {
List<Probe> probes = this.probeService.readAllByDomain(domain); List<Probe> probes = this.probeService.readAllByDomain(domain);
Assert.assertNotEquals(probes.size(), 0); Assert.assertEquals(probes.size(), 1);
} }