9e459078e1
paginationBar Done
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
#ifndef SENSORSERVICE_H
|
|
#define SENSORSERVICE_H
|
|
|
|
#include "utils.h"
|
|
#include "HttpClient.h"
|
|
#include "getsensors_r.h"
|
|
#include "getsensors_p.h"
|
|
#include "SensorGroups_r.h"
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
#include <QList>
|
|
#include <QStringList>
|
|
|
|
class SensorService : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SensorService(HttpClient* client, QObject *parent = nullptr)
|
|
: QObject(parent), httpClient(client) {}
|
|
|
|
QList<Sensor> getSensors(const QString& group) {
|
|
GetSensorsP requestParams;
|
|
requestParams.setGroup(group);
|
|
QByteArray requestData = requestParams.createRequestJson();
|
|
|
|
QJsonObject responseJson = httpClient->post(utils::API_URL + "/data/getDeviceSensors", QJsonDocument::fromJson(requestData).object());
|
|
|
|
GetSensorsR response;
|
|
response.parseResponse(responseJson);
|
|
|
|
return response.getSensors();
|
|
}
|
|
|
|
QStringList getSensorGroups() {
|
|
QJsonObject emptyJson;
|
|
QJsonObject responseJson = httpClient->post(utils::API_URL + "/data/getDeviceSensorGroups");
|
|
|
|
GetSensorsGroupsR response;
|
|
response.parseResponse(responseJson);
|
|
|
|
return response.getGroups();
|
|
}
|
|
|
|
private:
|
|
HttpClient* httpClient;
|
|
};
|
|
|
|
#endif // SENSORSERVICE_H
|