PNP_PIbd-31_Rodionov_I_A_Co.../service/serviceloaddb.h

49 lines
1.1 KiB
C
Raw Normal View History

2024-12-24 18:02:23 +04:00
#ifndef SERVICELOADDB_H
#define SERVICELOADDB_H
#include <QObject>
#include <QSql>
#include <QSqlDatabase>
#include <QSqlRecord>
#include <QSqlQuery>
#include <QSqlError>
#include <QString>
#include <QDebug>
#include <QStringList>
#include <QMap>
#include <QList>
#include <QFile>
#include "models/types.h" // IWYU pragma: keep
class ServiceLoadDB : public QObject
{
Q_OBJECT
2025-01-14 21:28:06 +04:00
2024-12-24 18:02:23 +04:00
public:
explicit ServiceLoadDB(QObject *parent = nullptr);
void start();
QMap<int, Location> loadLocations();
QMap<int, Department> loadDepartments();
QMap<int, Manufacturer> loadManufacturers();
QMap<int, DeviceType> loadDeviceTypes();
QMap<int, DeviceModel> loadDeviceModels();
QMap<int, Device> loadDevices();
bool updateDevice(const Device &device);
private:
QList<DeviceStructureElement> readStructureElements(int modelId);
2025-01-14 21:28:06 +04:00
template <typename T>
T getValueOrDefault(const QSqlQuery &query, const QSqlRecord &record, const QString &fieldName, const T &defaultValue);
2024-12-24 18:02:23 +04:00
private:
2025-01-14 21:28:06 +04:00
QSqlDatabase _db;
QString _dbInput;
QSqlQuery _query;
2024-12-24 18:02:23 +04:00
2025-01-14 21:28:06 +04:00
QMap<int, DeviceModel> _mapDeviceModels;
2024-12-24 18:02:23 +04:00
};
#endif // SERVICELOADDB_H