From adb08adc83dfe9dc5d6170c2322952d77a93c510 Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期三, 03 四月 2019 09:54:33 +0800
Subject: [PATCH] Merge branch 'yw.1.2' into yangwu1.3
---
QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h | 82 +++++++---------------------------------
1 files changed, 15 insertions(+), 67 deletions(-)
diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h b/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h
index 7592a5a..990265b 100755
--- a/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h
+++ b/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h
@@ -3,7 +3,7 @@
#define VSSLOCALSETTINGTBL_Sqlite_MANAGER_H
#include "../model/VssLocalSettingTbl.h"
-#include "BaseDao.h"
+#include "BaseSqliteDao.h"
#define VSSLocalSettingTbl_Sqlite_TABLE_NAME "VSSLocalSettingTbl"
@@ -11,23 +11,11 @@
/**
* 鏈湴鍥芥爣閰嶇疆绠$悊绫�
*/
-class VssLocalSettingTblSqliteDao : public BaseDao {
+class VssLocalSettingTblSqliteDao : public BaseSqliteDao {
private:
/** 鏈湴鍥芥爣閰嶇疆鏋勯�犲嚱鏁� */
VssLocalSettingTblSqliteDao() {}
-private:
- LDBTool* lDBTool;
- QSqlDatabase* m_db;
- QSqlTableModel *m_pModel;
- QMutex* m_mutexVisit;
-public:
- void setLDBTool(LDBTool* lDBTool) {
- this->lDBTool = lDBTool;
- this->m_db = lDBTool->get_m_db();
- this->m_pModel = lDBTool->get_m_pModel();
- this->m_mutexVisit = lDBTool->get_m_mutexVisit();
- }
public:
/** 鏈湴鍥芥爣閰嶇疆鍗曚緥妯″紡 */
static VssLocalSettingTblSqliteDao* instance() {
@@ -85,8 +73,9 @@
QMutexLocker mutexLocker(m_mutexVisit);//TODO
QSqlTableModel pModel(NULL, *m_db);
pModel.setTable(VSSLocalSettingTbl_Sqlite_TABLE_NAME);
- for (auto whereKeyValue : whereKeyValues ) {
- pModel.setFilter(QObject::tr((string(whereKeyValue.first)+" = '%1'").c_str()).arg(QString::fromUtf8(whereKeyValue.second.c_str())));
+ if (whereKeyValues.size() > 0) {
+ auto filter = QObject::tr((string(" 1=1 ")+getWhereColumnNameValuePair(whereKeyValues)).c_str());
+ pModel.setFilter(filter);
}
pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange
pModel.select();
@@ -119,13 +108,14 @@
Json::Value updateVssLocalSettingTbl(std::map<std::string, std::string>& keyValuesToUpdate,
std::map<std::string, std::string>& whereKeyValues) {
Json::Value responseJsonValue;
- responseJsonValue["message"] = "鍒犻櫎澶辫触锛�";
+ responseJsonValue["message"] = "鏇存柊澶辫触锛�";
responseJsonValue["success"] = "false";
QMutexLocker mutexLocker(m_mutexVisit);//TODO
QSqlTableModel pModel(NULL, *m_db);
pModel.setTable(VSSLocalSettingTbl_Sqlite_TABLE_NAME);
- for (auto whereKeyValue : whereKeyValues) {
- pModel.setFilter(QObject::tr((whereKeyValue.first + " = '%1'").c_str()).arg(QString::fromStdString(whereKeyValue.second)));
+ if (whereKeyValues.size() > 0) {
+ auto filter = QObject::tr((string(" 1=1 ")+getWhereColumnNameValuePair(whereKeyValues)).c_str());
+ pModel.setFilter(filter);
}
pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange
pModel.select();
@@ -157,7 +147,7 @@
if (pModel.submitAll()) {
m_db->commit();//鎻愪氦
responseJsonValue["success"] = "true";
- responseJsonValue["message"] = "鍒犻櫎鎴愬姛锛�";
+ responseJsonValue["message"] = "鏇存柊鎴愬姛锛�";
} else {
m_db->rollback();//鍥炴粴
ERR("updateLDeviceTable ,pModel_load Error: " << pModel.lastError().text().toStdString());
@@ -166,12 +156,12 @@
}
/** 鏇存柊鍒涘缓浜岀骇璁惧琛� keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */
- bool updateVssLocalSettingTbl(std::map<std::string, std::string>& keyValuesToUpdate,
+ Json::Value updateVssLocalSettingTbl(std::map<std::string, std::string>& keyValuesToUpdate,
string whereKey,
string whereValue) {
std::map<std::string, std::string> whereKeyValues;
whereKeyValues[whereKey] = whereValue;
- return update(keyValuesToUpdate, VSSLocalSettingTbl_TABLE_NAME, whereKeyValues);
+ return updateVssLocalSettingTbl(keyValuesToUpdate, whereKeyValues);
}
/** 鏌ヨ鏈湴鍥芥爣閰嶇疆鍒楄〃 querySql 瑕佹煡璇㈢殑sql璇彞 */
@@ -186,8 +176,9 @@
std::list<Record_Cut_Video_info> lst;
QSqlTableModel pModel(NULL, *m_db);
pModel.setTable(VSSLocalSettingTbl_Sqlite_TABLE_NAME);;
- for (auto whereKeyValue : whereKeyValues ) {
- pModel.setFilter(QObject::tr((string(whereKeyValue.first)+" = '%1'").c_str()).arg(QString::fromUtf8(whereKeyValue.second.c_str())));
+ if (whereKeyValues.size() > 0) {
+ auto filter = QObject::tr((string(" 1=1 ")+getWhereColumnNameValuePair(whereKeyValues)).c_str());
+ pModel.setFilter(filter);
}
pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange
pModel.select();
@@ -219,49 +210,6 @@
return findVssLocalSettingTblList(whereKeyValues);
}
- /** 鏌ヨmap鍒楄〃 querySql 瑕佹煡璇㈢殑sql璇彞 */
- vector<map<string, string>> findMapList(string querySql) {
- return findList(querySql);
- }
-
- /** 鎵цsql璇彞 */
- bool execute(string sql) {
- return exec(move(sql));
- }
-
- /** map杞琺odel绫� */
- VssLocalSettingTbl mapToModel(map<string, string>& rowData) {
- VssLocalSettingTbl vssLocalSettingTbl;
- string IDValue = rowData[VssLocalSettingTbl_ID];
- if (IDValue.length() != 0 && IDValue != "NULL") {
- vssLocalSettingTbl.ID = std::stoi(IDValue);
- }
- string ServerIpValue = rowData[VssLocalSettingTbl_ServerIp];
- if (ServerIpValue.length() != 0 && ServerIpValue != "NULL") {
- vssLocalSettingTbl.ServerIp = ServerIpValue;
- }
- string ServerPortValue = rowData[VssLocalSettingTbl_ServerPort];
- if (ServerPortValue.length() != 0 && ServerPortValue != "NULL") {
- vssLocalSettingTbl.ServerPort = ServerPortValue;
- }
- string ServerIdValue = rowData[VssLocalSettingTbl_ServerId];
- if (ServerIdValue.length() != 0 && ServerIdValue != "NULL") {
- vssLocalSettingTbl.ServerId = ServerIdValue;
- }
- string UserAuthIdValue = rowData[VssLocalSettingTbl_UserAuthId];
- if (UserAuthIdValue.length() != 0 && UserAuthIdValue != "NULL") {
- vssLocalSettingTbl.UserAuthId = UserAuthIdValue;
- }
- string PasswordValue = rowData[VssLocalSettingTbl_Password];
- if (PasswordValue.length() != 0 && PasswordValue != "NULL") {
- vssLocalSettingTbl.Password = PasswordValue;
- }
- string UpdateTimeValue = rowData[VssLocalSettingTbl_UpdateTime];
- if (UpdateTimeValue.length() != 0 && UpdateTimeValue != "NULL") {
- vssLocalSettingTbl.UpdateTime = UpdateTimeValue;
- }
- return vssLocalSettingTbl;
- }
};
--
Gitblit v1.8.0