RecordControlApplication/DatabaseManager.h
2024-08-11 20:26:42 -07:00

49 lines
1.2 KiB
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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; // 通道
QString year; // 年
QString month; // 月
QString day; // 日
QString time; // 时分秒hh:mm:ss
QString filename; // 真实路径
};
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