RecordControlApplication/DatabaseManager.h

45 lines
1.1 KiB
C
Raw Normal View History

2024-08-12 11:26:42 +08:00
#ifndef DATABASEMANAGER_H
#define DATABASEMANAGER_H
#include <QSqlDatabase>
#include <QVariantMap>
// 数据库管理类
class DatabaseManager {
public:
enum Channel {
MainChannel = 1,
SecondaryChannel
};
struct File {
int id; // id
Channel channel; // 通道
2024-08-23 13:34:58 +08:00
QString datetime; // 时间 yyyy-MM-dd hh:mm:ss
QString filename; // 文件名
2024-08-12 11:26:42 +08:00
};
static DatabaseManager* getInstace();
~DatabaseManager();
bool open();
void close();
bool insert(File file);
bool remove(DatabaseManager::Channel chn, QString name);
QList<DatabaseManager::File> getTopTwo();
QList<DatabaseManager::File> get(QVariantMap params);
QList<DatabaseManager::File> get(Channel chn);
QStringList getAllYears(Channel chn);
QStringList getAllMonths(Channel chn, QString year);
QStringList getAllDays(Channel, QString year, QString month);
private:
DatabaseManager();
private:
static DatabaseManager* instance;
QSqlDatabase db;
};
#endif // DATABASEMANAGER_H