added regist sensor

This commit is contained in:
snoop 2017-08-25 14:14:53 +09:00
parent a0ee8e6d95
commit d5f7921234
2 changed files with 23 additions and 0 deletions

View File

@ -21,6 +21,10 @@ public class SensorItemService {
return this.sensorItemDAO.save(sensorItem);
}
public boolean registAll(List<SensorItem> sensorItemList) {this.sensorItemDAO.save(sensorItemList);
return true;
}
public SensorItem read(String id) {
return this.sensorItemDAO.findOne(Long.valueOf(id));
}

View File

@ -8,10 +8,12 @@ import com.loafle.overflow.module.probe.model.Probe;
import com.loafle.overflow.module.probe.service.ProbeService;
import com.loafle.overflow.module.sensor.dao.SensorDAO;
import com.loafle.overflow.module.sensor.model.Sensor;
import com.loafle.overflow.module.sensor.model.SensorItem;
import com.loafle.overflow.module.target.model.Target;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;
/**
@ -29,6 +31,9 @@ public class SensorService {
@Autowired
private InfraService infraService;
@Autowired
private SensorItemService sensorItemService;
public Sensor regist(Sensor sensor) {
return this.sensorDAO.save(sensor);
}
@ -74,4 +79,18 @@ public class SensorService {
sensor.setStatus(status);
return this.sensorDAO.save(sensor);
}
@Transactional
public Sensor registSensorConfig(Sensor sensor, List<SensorItem> sensorItemList) {
this.sensorDAO.save(sensor);
for(SensorItem sensorItem : sensorItemList) {
sensorItem.setSensor(sensor);
}
this.sensorItemService.registAll(sensorItemList);
return sensor;
}
}