Merge remote-tracking branch 'origin/master'

This commit is contained in:
geek 2017-11-14 15:24:11 +09:00
commit 1d6faa8fd3

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.module.sensor.service;
import com.loafle.overflow.commons.model.PageParams;
import com.loafle.overflow.commons.utils.PageUtil;
import com.loafle.overflow.module.sensor.dao.SensorDAO;
import com.loafle.overflow.module.sensor.dao.SensorItemDAO;
import com.loafle.overflow.module.sensor.model.Sensor;
import com.loafle.overflow.module.sensor.model.SensorItem;
@ -9,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.List;
/**
@ -19,13 +21,24 @@ public class SensorItemService {
@Autowired
private SensorItemDAO sensorItemDAO;
@Autowired
private SensorDAO sensorDAO;
@Transactional
public SensorItem regist(SensorItem sensorItem) {
Sensor s = sensorItem.getSensor();
s.setItemCount((short)(s.getItemCount() + 1));
this.sensorDAO.save(s);
return this.sensorItemDAO.save(sensorItem);
}
public boolean registAll(List<SensorItem> sensorItemList) {this.sensorItemDAO.save(sensorItemList);
return true;
@Transactional
public boolean registAll(List<SensorItem> sensorItemList) {
Sensor s = sensorItemList.get(0).getSensor();
s.setItemCount((short)(s.getItemCount() + 1));
this.sensorDAO.save(s);
this.sensorItemDAO.save(sensorItemList);
return true;
}
public SensorItem read(String id) {
@ -36,7 +49,11 @@ public class SensorItemService {
return this.sensorItemDAO.findAllBySensor(sensor, PageUtil.getPageRequest(pageParams));
}
@Transactional
public void remove(SensorItem sensorItem) {
Sensor s = sensorItem.getSensor();
s.setItemCount((short)(s.getItemCount() - 1));
this.sensorDAO.save(s);
this.sensorItemDAO.delete(sensorItem);
}
}