test
This commit is contained in:
parent
7428634bf0
commit
313157683a
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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<Sensor> 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);
|
||||
}
|
||||
}
|
|
@ -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<Target> readAllByProbe(Probe probe) {
|
||||
return this.targetDAO.findAllByProbe(probe);
|
||||
}
|
||||
|
||||
public void remove(Target target) {
|
||||
this.targetDAO.delete(target);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user