From bcf8d8c62fdf61c4c3091bbf0db32383cbd5ea9e Mon Sep 17 00:00:00 2001 From: pansen <pansen626@sina.com> Date: 星期四, 28 二月 2019 14:24:09 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/yw.1.2.fixbug' into yw.1.2 --- QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblDao.h | 126 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 126 insertions(+), 0 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblDao.h b/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblDao.h new file mode 100755 index 0000000..22a8f82 --- /dev/null +++ b/QiaoJiaSystem/DataManagerServer/vss/dao/VssLocalSettingTblDao.h @@ -0,0 +1,126 @@ + +#ifndef VSSLOCALSETTINGTBL_MANAGER_H +#define VSSLOCALSETTINGTBL_MANAGER_H + +#include "../model/VssLocalSettingTbl.h" +#include "BaseDao.h" + +#define VSSLocalSettingTbl_TABLE_NAME "VSSLocalSettingTbl" + +/** + * 鏈湴鍥芥爣閰嶇疆绠$悊绫� + */ +class VssLocalSettingTblDao : public BaseDao { +private: + /** 鏈湴鍥芥爣閰嶇疆鏋勯�犲嚱鏁� */ + VssLocalSettingTblDao() {} +public: + /** 鏈湴鍥芥爣閰嶇疆鍗曚緥妯″紡 */ + static VssLocalSettingTblDao* instance() { + static VssLocalSettingTblDao instance; + return &instance; + } + + /** 娣诲姞鏈湴鍥芥爣閰嶇疆 keyValuesToAdd 闇�瑕佹坊鍔犵殑鍒楀悕鍜屽垪鍊煎map*/ + mysqlpp::SimpleResult addVssLocalSettingTbl(std::map<std::string, std::string>& keyValuesToAdd) { + return add(keyValuesToAdd, VSSLocalSettingTbl_TABLE_NAME); + } + + /** 鍒犻櫎鏈湴鍥芥爣閰嶇疆 whereKey 鍒楀悕锛泈hereValue 鍒楀�� */ + bool deleteByColumn(string whereKey, string whereValue) { + std::map<std::string, std::string> whereKeyValues; + whereKeyValues[whereKey] = whereValue; + return deleteVssLocalSettingTbl(whereKeyValues); + } + + /** 鍒犻櫎鏈湴鍥芥爣閰嶇疆 whereColumnNameValues 鍒楀悕鍜屽垪鍊煎鏉′欢 */ + bool deleteVssLocalSettingTbl(std::map<std::string, std::string>& whereKeyValues) { + return del(VSSLocalSettingTbl_TABLE_NAME, whereKeyValues); + } + + /** 鏇存柊鏈湴鍥芥爣閰嶇疆 keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */ + bool updateVssLocalSettingTbl(std::map<std::string, std::string>& keyValuesToUpdate, + std::map<std::string, std::string>& whereKeyValues) { + return update(keyValuesToUpdate, VSSLocalSettingTbl_TABLE_NAME, whereKeyValues); + } + + /** 鏇存柊鍒涘缓浜岀骇璁惧琛� keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */ + bool 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); + } + + /** 鏌ヨ鏈湴鍥芥爣閰嶇疆鍒楄〃 querySql 瑕佹煡璇㈢殑sql璇彞 */ + vector<VssLocalSettingTbl> findVssLocalSettingTblList(string querySql) { + vector<VssLocalSettingTbl> vssLocalSettingTblVec; + vector<map<string, string>> rowDatList = findList(querySql); + vssLocalSettingTblVec.reserve(rowDatList.size()); + for (auto rowData : rowDatList) { + vssLocalSettingTblVec.emplace_back(mapToModel(rowData)); + } + return vssLocalSettingTblVec; + } + + /**鏌ヨ鏈湴鍥芥爣閰嶇疆鍒楄〃 whereKeyValues 鍒楀悕鍜屽垪鍊煎鏉′欢 */ + vector<VssLocalSettingTbl> findVssLocalSettingTblList(std::map<std::string, std::string>& whereKeyValues) { + return findVssLocalSettingTblList(string("select * from ") + VSSLocalSettingTbl_TABLE_NAME + " where 1=1 " + getWhereColumnNameValuePair(whereKeyValues)); + } + + /**鏌ヨ鎵�鏈夋湰鍦板浗鏍囬厤缃垪琛� */ + vector<VssLocalSettingTbl> findAllVssLocalSettingTblList() { + return findVssLocalSettingTblList(string("select * from ") + VSSLocalSettingTbl_TABLE_NAME + " where 1=1 "); + } + + /** 鏌ヨ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; + } + +}; + + +#endif //VSSLOCALSETTINGTBL_MANAGER_H + + -- Gitblit v1.8.0