2025-03-14 16:06:20 +08:00
|
|
|
|
#ifndef SQLQUERYEXECUTOR_H
|
|
|
|
|
|
#define SQLQUERYEXECUTOR_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
#include <QSqlQuery>
|
|
|
|
|
|
#include <QMap>
|
|
|
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
|
|
|
|
class SqlQueryExecutor : public QObject
|
|
|
|
|
|
{
|
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
static SqlQueryExecutor& instance();
|
|
|
|
|
|
//基础SQL语句执行接口
|
2025-03-17 14:46:52 +08:00
|
|
|
|
QSqlQuery executeSQL(const QString& strConnectionName, const QString& strSQL, const QVariantHash& params = {}, bool useTranscation = false);
|
2025-03-14 16:06:20 +08:00
|
|
|
|
//基于具体业务的查询接口-对外调用
|
|
|
|
|
|
const QVector<Model> getModels(const QString&);
|
|
|
|
|
|
const QVector<AttributeGroup> getAttributeGroup(const QString&);
|
|
|
|
|
|
const QString getArributeGropuName(const QString&, int);
|
|
|
|
|
|
bool addModel(const QString&, Model&);
|
|
|
|
|
|
bool modelNameExistsInDB(const QString&, const QString&);
|
|
|
|
|
|
bool modelTypeExistsInDB(const QString&, const QString&);
|
2025-03-14 18:08:43 +08:00
|
|
|
|
bool removeMode(const QString&, int);
|
2025-03-14 16:06:20 +08:00
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
void errorOccurred(const QString& error);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
explicit SqlQueryExecutor();
|
|
|
|
|
|
~SqlQueryExecutor();
|
|
|
|
|
|
// 禁止拷贝
|
|
|
|
|
|
SqlQueryExecutor(const SqlQueryExecutor&) = delete; //delete关键字表示该函数不可用,包括编译器自动生成的函数
|
|
|
|
|
|
SqlQueryExecutor& operator=(const SqlQueryExecutor&) = delete;
|
|
|
|
|
|
//基于具体业务的查询接口-内部调用
|
|
|
|
|
|
QVector<int> getModelGroups(const QString&, int);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SQLQUERYEXECUTOR_H
|