targetservice fix

This commit is contained in:
insanity 2018-04-30 19:44:15 +09:00
parent dea99696c4
commit 1870cb5d47
4 changed files with 20 additions and 11 deletions

View File

@ -45,6 +45,11 @@ public class CentralProbeService implements ProbeService {
return this.probeDAO.save(probe); return this.probeDAO.save(probe);
} }
public boolean remove(long id) throws OverflowException {
this.probeDAO.delete(id);
return true;
}
public Probe increaseTargetCount(Probe probe) { public Probe increaseTargetCount(Probe probe) {
Probe p = this.probeDAO.findOne(probe.getId()); Probe p = this.probeDAO.findOne(probe.getId());
p.setTargetCount(p.getTargetCount() + 1); p.setTargetCount(p.getTargetCount() + 1);
@ -59,4 +64,5 @@ public class CentralProbeService implements ProbeService {
} }
return this.probeDAO.save(p); return this.probeDAO.save(p);
} }
} }

View File

@ -17,6 +17,7 @@ import com.loafle.overflow.service.central.infra.InfraService;
import com.loafle.overflow.service.central.probe.ProbeService; import com.loafle.overflow.service.central.probe.ProbeService;
import com.loafle.overflow.service.central.sensor.SensorItemService; import com.loafle.overflow.service.central.sensor.SensorItemService;
import com.loafle.overflow.service.central.sensor.SensorService; import com.loafle.overflow.service.central.sensor.SensorService;
import com.loafle.overflow.service.central.target.TargetService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@ -47,7 +48,7 @@ public class CentralSensorService implements SensorService {
private SensorConfigGenerator sensorConfigGenerator; private SensorConfigGenerator sensorConfigGenerator;
@Autowired @Autowired
private CentralTargetService targetService; private TargetService targetService;
@Transactional @Transactional
public Sensor regist(Sensor sensor) throws OverflowException { public Sensor regist(Sensor sensor) throws OverflowException {

View File

@ -25,7 +25,7 @@ import java.util.List;
public class CentralTargetDiscoveryService implements TargetDiscoveryService{ public class CentralTargetDiscoveryService implements TargetDiscoveryService{
@Autowired @Autowired
private CentralTargetService targetService; private TargetService targetService;
@Autowired @Autowired
private CentralInfraMachineService infraMachineService; private CentralInfraMachineService infraMachineService;

View File

@ -1,7 +1,5 @@
package com.loafle.overflow.central.module.target.service; package com.loafle.overflow.central.module.target.service;
import javax.transaction.Transactional;
import com.loafle.overflow.central.module.probe.service.CentralProbeService; import com.loafle.overflow.central.module.probe.service.CentralProbeService;
import com.loafle.overflow.central.module.target.dao.TargetDAO; import com.loafle.overflow.central.module.target.dao.TargetDAO;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
@ -11,6 +9,7 @@ import com.loafle.overflow.service.central.target.TargetService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/** /**
* Created by insanity on 17. 6. 28. * Created by insanity on 17. 6. 28.
@ -23,9 +22,8 @@ public class CentralTargetService implements TargetService {
@Autowired @Autowired
private CentralProbeService probeService; private CentralProbeService probeService;
@Transactional @Transactional
public Target regist(Target target, Probe probe) throws OverflowException { public Target regist(Target target, Probe probe) throws OverflowException {
this.probeService.increaseTargetCount(probe); this.probeService.increaseTargetCount(probe);
return this.targetDAO.save(target); return this.targetDAO.save(target);
} }
@ -36,12 +34,16 @@ public class CentralTargetService implements TargetService {
this.targetDAO.delete(target); this.targetDAO.delete(target);
} }
public Target read(String id) throws OverflowException { public Target read(String id) throws OverflowException {
return this.targetDAO.findOne(Long.valueOf(id)); return this.targetDAO.findOne(Long.valueOf(id));
} }
public Target modify(Target target) throws OverflowException {
return this.targetDAO.save(target);
}
@Deprecated @Deprecated
public Target regist(Target target) throws OverflowException { public Target regist(Target target) throws OverflowException {
return this.targetDAO.save(target); return this.targetDAO.save(target);
} }