From 5bf0020b189b2bc8c64737c2af4ea77c3e8f5612 Mon Sep 17 00:00:00 2001 From: xuxiuxi <554325746@qq.com> Date: 星期五, 08 三月 2019 22:24:27 +0800 Subject: [PATCH] Merge branch 'yw.1.2.fixbug' of http://192.168.1.226:10010/r/development/c++ into yw.1.2.fixbug --- QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h | 79 ++++----------------------------------- 1 files changed, 9 insertions(+), 70 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h b/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblSqliteDao.h index 7592a5a..04b5d63 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,9 +73,7 @@ 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()))); - } + pModel.setFilter(QObject::tr(getWhereColumnNameValuePair(whereKeyValues).c_str())); pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange pModel.select(); @@ -119,14 +105,12 @@ 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))); - } + pModel.setFilter(QObject::tr(getWhereColumnNameValuePair(whereKeyValues).c_str())); pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange pModel.select(); @@ -157,7 +141,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 +150,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,9 +170,7 @@ 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()))); - } + pModel.setFilter(QObject::tr(getWhereColumnNameValuePair(whereKeyValues).c_str())); pModel.setEditStrategy(QSqlTableModel::OnManualSubmit);//OnManualSubmit OnFieldChange pModel.select(); @@ -219,49 +201,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