Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c490167a79
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.loafle.overflow.module.sensor.dao;
|
||||
|
||||
|
||||
import com.loafle.overflow.module.probe.model.Probe;
|
||||
import com.loafle.overflow.module.sensor.model.Sensor;
|
||||
import com.loafle.overflow.module.target.model.Target;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
@ -21,4 +20,5 @@ public interface SensorDAO extends JpaRepository<Sensor, Long> {
|
|||
@Query("SELECT s from Sensor s WHERE s.target in (:targetList)")
|
||||
List<Sensor> findAllByTarget(@Param("targetList") List<Target> targetList);
|
||||
// List<Sensor> findAllByTargetList(List<Target> targets);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user