diff --git a/src/main/java/com/loafle/overflow/module/commons/OFService.java b/src/main/java/com/loafle/overflow/module/commons/OFService.java deleted file mode 100644 index d28c451..0000000 --- a/src/main/java/com/loafle/overflow/module/commons/OFService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.loafle.overflow.module.commons; - -import org.codehaus.jackson.map.ObjectMapper; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * Created by insanity on 17. 6. 28. - */ -public class OFService { - - @Autowired - private ObjectMapper mapper; - - public String toString(Object o) { - try { - return mapper.writeValueAsString(o); - }catch(Exception e) { - return e.getMessage(); - } - } -} diff --git a/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java b/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java new file mode 100644 index 0000000..291daf2 --- /dev/null +++ b/src/main/java/com/loafle/overflow/module/sensor/service/SensorService.java @@ -0,0 +1,33 @@ +package com.loafle.overflow.module.sensor.service; + +import com.loafle.overflow.module.sensor.dao.SensorDAO; +import com.loafle.overflow.module.sensor.model.Sensor; +import com.loafle.overflow.module.target.model.Target; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.List; + +/** + * Created by insanity on 17. 6. 28. + */ +public class SensorService { + + @Autowired + SensorDAO sensorDAO; + + public Sensor regist(Sensor sensor) { + return this.sensorDAO.save(sensor); + } + + public List readAllByTarget(Target target) { + return this.sensorDAO.findAllByTarget(target); + } + + public Sensor read(String id) { + return this.sensorDAO.findOne(Long.valueOf(id)); + } + + public void remove(Sensor sensor) { + this.sensorDAO.delete(sensor); + } +} diff --git a/src/main/java/com/loafle/overflow/module/target/service/TargetService.java b/src/main/java/com/loafle/overflow/module/target/service/TargetService.java index c8e809a..bca0f3e 100644 --- a/src/main/java/com/loafle/overflow/module/target/service/TargetService.java +++ b/src/main/java/com/loafle/overflow/module/target/service/TargetService.java @@ -1,27 +1,34 @@ package com.loafle.overflow.module.target.service; - -import com.loafle.overflow.module.commons.OFService; +import com.loafle.overflow.module.probe.model.Probe; import com.loafle.overflow.module.target.dao.TargetDAO; import com.loafle.overflow.module.target.model.Target; import org.springframework.beans.factory.annotation.Autowired; +import java.util.List; + /** * Created by insanity on 17. 6. 28. */ -public class TargetService extends OFService { +public class TargetService { @Autowired private TargetDAO targetDAO; - public String regist(Target target) { - Target t = this.targetDAO.save(target); - return toString(t); + public Target regist(Target target) { + return this.targetDAO.save(target); } - public String read(String id) { - Target t = this.targetDAO.findOne(Long.valueOf(id)); - return toString(t); + public Target read(String id) { + return this.targetDAO.findOne(Long.valueOf(id)); + } + + public List readAllByProbe(Probe probe) { + return this.targetDAO.findAllByProbe(probe); + } + + public void remove(Target target) { + this.targetDAO.delete(target); } }