probe service

This commit is contained in:
insanity 2017-08-23 10:40:46 +09:00
parent 1f053db7eb
commit 42842489f2
2 changed files with 16 additions and 6 deletions

View File

@ -9,9 +9,12 @@ import com.loafle.overflow.module.noauthprobe.model.NoAuthProbe;
import com.loafle.overflow.module.probe.model.Probe;
import com.loafle.overflow.module.probe.service.ProbeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* Created by snoop on 17. 6. 28.
@ -30,6 +33,7 @@ public class NoAuthProbeService {
return this.noAuthProbeDAO.save(noAuthProbe);
}
public List<NoAuthProbe> readAllByDomain(Domain domain) {
return this.noAuthProbeDAO.findAllByDomain(domain);
@ -41,13 +45,15 @@ public class NoAuthProbeService {
public List<NoAuthProbe> acceptNoAuthProbes(List<NoAuthProbe> noAuthProbes) {
// Todo encryption key generation & probe key generation
// Todo domain injection & member injection
// List<Probe> resProbe = new ArrayList<>();
List<Probe> probes = new ArrayList<>();
Probe probe = null;
for (NoAuthProbe noAuth : noAuthProbes) {
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String key = passwordEncoder.encode(UUID.randomUUID().toString());
probe = new Probe();
probe.setEncryptionKey(key);
probe.setProbeKey(noAuth.getApiKey());
probe.setDomain(new Domain(1));
probe.setAuthorizeMember(new Member(1));
@ -57,11 +63,12 @@ public class NoAuthProbeService {
probe.setEncryptionKey("111");
probe.setDisplayName(noAuth.getHostName()+"'s probe");
// resprobe.add(probe);
this.probeService.regist(probe);
probes.add(probe);
noAuth.setStatus(new MetaNoAuthProbeStatus((short) 1));
}
this.probeService.regist(probes);
this.noAuthProbeDAO.save(noAuthProbes);
return this.readAllByDomain(noAuthProbes.get(0).getDomain());
}

View File

@ -21,8 +21,11 @@ public class ProbeService {
return this.probeDAO.save(probe);
}
public List<Probe> readAllByDomain(Domain domain) {
public List<Probe> regist(List<Probe> probes) {
return this.probeDAO.save(probes);
}
public List<Probe> readAllByDomain(Domain domain) {
return this.probeDAO.findAllByDomainOrderByIdDesc(domain);
}