Add telemetry registration
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package be.naaturel.boardmateapi.services;
|
||||
|
||||
import be.naaturel.boardmateapi.common.exceptions.ServiceException;
|
||||
import be.naaturel.boardmateapi.common.models.TelemetryData;
|
||||
import be.naaturel.boardmateapi.repository.TelemetryRepo;
|
||||
import be.naaturel.boardmateapi.repository.dtos.TelemetryDataDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TelemetryService {
|
||||
|
||||
private final TelemetryRepo repo;
|
||||
|
||||
@Autowired
|
||||
public TelemetryService(TelemetryRepo repo){
|
||||
this.repo = repo;
|
||||
}
|
||||
|
||||
public void insert(TelemetryData telemetry) throws ServiceException {
|
||||
try{
|
||||
TelemetryDataDto dto = new TelemetryDataDto();
|
||||
dto.setClientId(telemetry.getClientId());
|
||||
dto.setData(telemetry.getData());
|
||||
repo.insert(dto);
|
||||
} catch (Exception e){
|
||||
throw new ServiceException("Failed to add telemetry data : " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user