From ed223aee5fe5f3b222488549597976f34c679c3d Mon Sep 17 00:00:00 2001 From: pansen <pansen626@sina.com> Date: 星期二, 05 三月 2019 14:00:47 +0800 Subject: [PATCH] 代码格式化及部分bug修改 --- QiaoJiaSystem/DataManagerServer/vss/dao/VssUpperSvrTblDao.h | 324 +++++++++++++++++++++++++++--------------------------- 1 files changed, 162 insertions(+), 162 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/vss/dao/VssUpperSvrTblDao.h b/QiaoJiaSystem/DataManagerServer/vss/dao/VssUpperSvrTblDao.h index 1f2bdf8..e4a549e 100755 --- a/QiaoJiaSystem/DataManagerServer/vss/dao/VssUpperSvrTblDao.h +++ b/QiaoJiaSystem/DataManagerServer/vss/dao/VssUpperSvrTblDao.h @@ -1,162 +1,162 @@ - -#ifndef VSSUPPERSVRTBL_MANAGER_H -#define VSSUPPERSVRTBL_MANAGER_H - -#include "../model/VssUpperSvrTbl.h" -#include "BaseDao.h" - -#define VSSUpperSvrTbl_TABLE_NAME "VSSUpperSvrTbl" - -/** - * 鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃绠$悊绫� - */ -class VssUpperSvrTblDao : public BaseDao { -private: - /** 鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃鏋勯�犲嚱鏁� */ - VssUpperSvrTblDao() {} -public: - /** 鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃鍗曚緥妯″紡 */ - static VssUpperSvrTblDao* instance() { - static VssUpperSvrTblDao instance; - return &instance; - } - - /** 娣诲姞鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃 keyValuesToAdd 闇�瑕佹坊鍔犵殑鍒楀悕鍜屽垪鍊煎map*/ - mysqlpp::SimpleResult addVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToAdd) { - return add(keyValuesToAdd, VSSUpperSvrTbl_TABLE_NAME); - } - - /** 鍒犻櫎鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃 whereKey 鍒楀悕锛泈hereValue 鍒楀�� */ - bool deleteByColumn(string whereKey, string whereValue) { - std::map<std::string, std::string> whereKeyValues; - whereKeyValues[whereKey] = whereValue; - return deleteVssUpperSvrTbl(whereKeyValues); - } - - /** 鍒犻櫎鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃 whereColumnNameValues 鍒楀悕鍜屽垪鍊煎鏉′欢 */ - bool deleteVssUpperSvrTbl(std::map<std::string, std::string>& whereKeyValues) { - return del(VSSUpperSvrTbl_TABLE_NAME, whereKeyValues); - } - - /** 鏇存柊鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃 keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */ - bool updateVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToUpdate, - std::map<std::string, std::string>& whereKeyValues) { - return update(keyValuesToUpdate, VSSUpperSvrTbl_TABLE_NAME, whereKeyValues); - } - - /** 鏇存柊鍒涘缓浜岀骇璁惧琛� keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */ - bool updateVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToUpdate, - string whereKey, - string whereValue) { - std::map<std::string, std::string> whereKeyValues; - whereKeyValues[whereKey] = whereValue; - return update(keyValuesToUpdate, VSSUpperSvrTbl_TABLE_NAME, whereKeyValues); - } - - /** 鏌ヨ鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃鍒楄〃 querySql 瑕佹煡璇㈢殑sql璇彞 */ - vector<VssUpperSvrTbl> findVssUpperSvrTblList(string querySql) { - vector<VssUpperSvrTbl> vssUpperSvrTblVec; - vector<map<string, string>> rowDatList = findList(querySql); - vssUpperSvrTblVec.reserve(rowDatList.size()); - for (auto rowData : rowDatList) { - vssUpperSvrTblVec.emplace_back(mapToModel(rowData)); - } - return vssUpperSvrTblVec; - } - - /**鏌ヨ鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃鍒楄〃 whereKeyValues 鍒楀悕鍜屽垪鍊煎鏉′欢 */ - vector<VssUpperSvrTbl> findVssUpperSvrTblList(std::map<std::string, std::string>& whereKeyValues) { - return findVssUpperSvrTblList(string("select * from ") + VSSUpperSvrTbl_TABLE_NAME + " where 1=1 " + getWhereColumnNameValuePair(whereKeyValues)); - } - - /**鏌ヨ鎵�鏈夊垱寤轰笂绾у钩鍙版湇鍔″櫒琛ㄥ垪琛� */ - vector<VssUpperSvrTbl> findAllVssUpperSvrTblList() { - return findVssUpperSvrTblList(string("select * from ") + VSSUpperSvrTbl_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绫� */ - VssUpperSvrTbl mapToModel(map<string, string>& rowData) { - VssUpperSvrTbl vssUpperSvrTbl; - string IDValue = rowData[VssUpperSvrTbl_ID]; - if (IDValue.length() != 0 && IDValue != "NULL") { - vssUpperSvrTbl.ID = std::stoi(IDValue); - } - string NameValue = rowData[VssUpperSvrTbl_Name]; - if (NameValue.length() != 0 && NameValue != "NULL") { - vssUpperSvrTbl.Name = NameValue; - } - string PublicIDValue = rowData[VssUpperSvrTbl_PublicID]; - if (PublicIDValue.length() != 0 && PublicIDValue != "NULL") { - vssUpperSvrTbl.PublicID = PublicIDValue; - } - string AuthUsernameValue = rowData[VssUpperSvrTbl_AuthUsername]; - if (AuthUsernameValue.length() != 0 && AuthUsernameValue != "NULL") { - vssUpperSvrTbl.AuthUsername = AuthUsernameValue; - } - string AuthPasswdValue = rowData[VssUpperSvrTbl_AuthPasswd]; - if (AuthPasswdValue.length() != 0 && AuthPasswdValue != "NULL") { - vssUpperSvrTbl.AuthPasswd = AuthPasswdValue; - } - string DomainValue = rowData[VssUpperSvrTbl_Domain]; - if (DomainValue.length() != 0 && DomainValue != "NULL") { - vssUpperSvrTbl.Domain = DomainValue; - } - string IPValue = rowData[VssUpperSvrTbl_IP]; - if (IPValue.length() != 0 && IPValue != "NULL") { - vssUpperSvrTbl.IP = IPValue; - } - string PortValue = rowData[VssUpperSvrTbl_Port]; - if (PortValue.length() != 0 && PortValue != "NULL") { - vssUpperSvrTbl.Port = std::stoi(PortValue); - } - string RegisterTimeValue = rowData[VssUpperSvrTbl_RegisterTime]; - if (RegisterTimeValue.length() != 0 && RegisterTimeValue != "NULL") { - vssUpperSvrTbl.RegisterTime = std::stoi(RegisterTimeValue); - } - string KeepAliveTimeValue = rowData[VssUpperSvrTbl_KeepAliveTime]; - if (KeepAliveTimeValue.length() != 0 && KeepAliveTimeValue != "NULL") { - vssUpperSvrTbl.KeepAliveTime = std::stoi(KeepAliveTimeValue); - } - string AliveValue = rowData[VssUpperSvrTbl_Alive]; - if (AliveValue.length() != 0 && AliveValue != "NULL") { - vssUpperSvrTbl.Alive = std::stoi(AliveValue); - } - string IsSyncTimeValue = rowData[VssUpperSvrTbl_IsSyncTime]; - if (IsSyncTimeValue.length() != 0 && IsSyncTimeValue != "NULL") { - vssUpperSvrTbl.IsSyncTime = std::stoi(IsSyncTimeValue); - } - string PushProtocolValue = rowData[VssUpperSvrTbl_PushProtocol]; - if (PushProtocolValue.length() != 0 && PushProtocolValue != "NULL") { - vssUpperSvrTbl.PushProtocol = std::stoi(PushProtocolValue); - } - string PlatformInfoValue = rowData[VssUpperSvrTbl_PlatformInfo]; - if (PlatformInfoValue.length() != 0 && PlatformInfoValue != "NULL") { - vssUpperSvrTbl.PlatformInfo = std::stoi(PlatformInfoValue); - } - string IsEnableValue = rowData[VssUpperSvrTbl_IsEnable]; - if (IsEnableValue.length() != 0 && IsEnableValue != "NULL") { - vssUpperSvrTbl.IsEnable = std::stoi(IsEnableValue); - } - string UpdateTimeValue = rowData[VssUpperSvrTbl_UpdateTime]; - if (UpdateTimeValue.length() != 0 && UpdateTimeValue != "NULL") { - vssUpperSvrTbl.UpdateTime = UpdateTimeValue; - } - return vssUpperSvrTbl; - } - -}; - - -#endif //VSSUPPERSVRTBL_MANAGER_H - - + +#ifndef VSSUPPERSVRTBL_MANAGER_H +#define VSSUPPERSVRTBL_MANAGER_H + +#include "../model/VssUpperSvrTbl.h" +#include "BaseDao.h" + +#define VSSUpperSvrTbl_TABLE_NAME "VSSUpperSvrTbl" + +/** + * 鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃绠$悊绫� + */ +class VssUpperSvrTblDao : public BaseDao { +private: + /** 鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃鏋勯�犲嚱鏁� */ + VssUpperSvrTblDao() {} +public: + /** 鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃鍗曚緥妯″紡 */ + static VssUpperSvrTblDao* instance() { + static VssUpperSvrTblDao instance; + return &instance; + } + + /** 娣诲姞鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃 keyValuesToAdd 闇�瑕佹坊鍔犵殑鍒楀悕鍜屽垪鍊煎map*/ + mysqlpp::SimpleResult addVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToAdd) { + return add(keyValuesToAdd, VSSUpperSvrTbl_TABLE_NAME); + } + + /** 鍒犻櫎鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃 whereKey 鍒楀悕锛泈hereValue 鍒楀�� */ + bool deleteByColumn(string whereKey, string whereValue) { + std::map<std::string, std::string> whereKeyValues; + whereKeyValues[whereKey] = whereValue; + return deleteVssUpperSvrTbl(whereKeyValues); + } + + /** 鍒犻櫎鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃 whereColumnNameValues 鍒楀悕鍜屽垪鍊煎鏉′欢 */ + bool deleteVssUpperSvrTbl(std::map<std::string, std::string>& whereKeyValues) { + return del(VSSUpperSvrTbl_TABLE_NAME, whereKeyValues); + } + + /** 鏇存柊鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃 keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */ + bool updateVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToUpdate, + std::map<std::string, std::string>& whereKeyValues) { + return update(keyValuesToUpdate, VSSUpperSvrTbl_TABLE_NAME, whereKeyValues); + } + + /** 鏇存柊鍒涘缓浜岀骇璁惧琛� keyValuesToUpdate 闇�瑕佹洿鏂扮殑鍒楀悕鍜屽垪鍊煎锛� whereKeyValues 鍒楀悕鍜屽垪鍊兼潯浠� */ + bool updateVssUpperSvrTbl(std::map<std::string, std::string>& keyValuesToUpdate, + string whereKey, + string whereValue) { + std::map<std::string, std::string> whereKeyValues; + whereKeyValues[whereKey] = whereValue; + return update(keyValuesToUpdate, VSSUpperSvrTbl_TABLE_NAME, whereKeyValues); + } + + /** 鏌ヨ鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃鍒楄〃 querySql 瑕佹煡璇㈢殑sql璇彞 */ + vector<VssUpperSvrTbl> findVssUpperSvrTblList(string querySql) { + vector<VssUpperSvrTbl> vssUpperSvrTblVec; + vector<map<string, string>> rowDatList = findList(querySql); + vssUpperSvrTblVec.reserve(rowDatList.size()); + for (auto rowData : rowDatList) { + vssUpperSvrTblVec.emplace_back(mapToModel(rowData)); + } + return vssUpperSvrTblVec; + } + + /**鏌ヨ鍒涘缓涓婄骇骞冲彴鏈嶅姟鍣ㄨ〃鍒楄〃 whereKeyValues 鍒楀悕鍜屽垪鍊煎鏉′欢 */ + vector<VssUpperSvrTbl> findVssUpperSvrTblList(std::map<std::string, std::string>& whereKeyValues) { + return findVssUpperSvrTblList(string("select * from ") + VSSUpperSvrTbl_TABLE_NAME + " where 1=1 " + getWhereColumnNameValuePair(whereKeyValues)); + } + + /**鏌ヨ鎵�鏈夊垱寤轰笂绾у钩鍙版湇鍔″櫒琛ㄥ垪琛� */ + vector<VssUpperSvrTbl> findAllVssUpperSvrTblList() { + return findVssUpperSvrTblList(string("select * from ") + VSSUpperSvrTbl_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绫� */ + VssUpperSvrTbl mapToModel(map<string, string>& rowData) { + VssUpperSvrTbl vssUpperSvrTbl; + string IDValue = rowData[VssUpperSvrTbl_ID]; + if (IDValue.length() != 0 && IDValue != "NULL") { + vssUpperSvrTbl.ID = std::stoi(IDValue); + } + string NameValue = rowData[VssUpperSvrTbl_Name]; + if (NameValue.length() != 0 && NameValue != "NULL") { + vssUpperSvrTbl.Name = NameValue; + } + string PublicIDValue = rowData[VssUpperSvrTbl_PublicID]; + if (PublicIDValue.length() != 0 && PublicIDValue != "NULL") { + vssUpperSvrTbl.PublicID = PublicIDValue; + } + string AuthUsernameValue = rowData[VssUpperSvrTbl_AuthUsername]; + if (AuthUsernameValue.length() != 0 && AuthUsernameValue != "NULL") { + vssUpperSvrTbl.AuthUsername = AuthUsernameValue; + } + string AuthPasswdValue = rowData[VssUpperSvrTbl_AuthPasswd]; + if (AuthPasswdValue.length() != 0 && AuthPasswdValue != "NULL") { + vssUpperSvrTbl.AuthPasswd = AuthPasswdValue; + } + string DomainValue = rowData[VssUpperSvrTbl_Domain]; + if (DomainValue.length() != 0 && DomainValue != "NULL") { + vssUpperSvrTbl.Domain = DomainValue; + } + string IPValue = rowData[VssUpperSvrTbl_IP]; + if (IPValue.length() != 0 && IPValue != "NULL") { + vssUpperSvrTbl.IP = IPValue; + } + string PortValue = rowData[VssUpperSvrTbl_Port]; + if (PortValue.length() != 0 && PortValue != "NULL") { + vssUpperSvrTbl.Port = std::stoi(PortValue); + } + string RegisterTimeValue = rowData[VssUpperSvrTbl_RegisterTime]; + if (RegisterTimeValue.length() != 0 && RegisterTimeValue != "NULL") { + vssUpperSvrTbl.RegisterTime = std::stoi(RegisterTimeValue); + } + string KeepAliveTimeValue = rowData[VssUpperSvrTbl_KeepAliveTime]; + if (KeepAliveTimeValue.length() != 0 && KeepAliveTimeValue != "NULL") { + vssUpperSvrTbl.KeepAliveTime = std::stoi(KeepAliveTimeValue); + } + string AliveValue = rowData[VssUpperSvrTbl_Alive]; + if (AliveValue.length() != 0 && AliveValue != "NULL") { + vssUpperSvrTbl.Alive = std::stoi(AliveValue); + } + string IsSyncTimeValue = rowData[VssUpperSvrTbl_IsSyncTime]; + if (IsSyncTimeValue.length() != 0 && IsSyncTimeValue != "NULL") { + vssUpperSvrTbl.IsSyncTime = std::stoi(IsSyncTimeValue); + } + string PushProtocolValue = rowData[VssUpperSvrTbl_PushProtocol]; + if (PushProtocolValue.length() != 0 && PushProtocolValue != "NULL") { + vssUpperSvrTbl.PushProtocol = std::stoi(PushProtocolValue); + } + string PlatformInfoValue = rowData[VssUpperSvrTbl_PlatformInfo]; + if (PlatformInfoValue.length() != 0 && PlatformInfoValue != "NULL") { + vssUpperSvrTbl.PlatformInfo = std::stoi(PlatformInfoValue); + } + string IsEnableValue = rowData[VssUpperSvrTbl_IsEnable]; + if (IsEnableValue.length() != 0 && IsEnableValue != "NULL") { + vssUpperSvrTbl.IsEnable = std::stoi(IsEnableValue); + } + string UpdateTimeValue = rowData[VssUpperSvrTbl_UpdateTime]; + if (UpdateTimeValue.length() != 0 && UpdateTimeValue != "NULL") { + vssUpperSvrTbl.UpdateTime = UpdateTimeValue; + } + return vssUpperSvrTbl; + } + +}; + + +#endif //VSSUPPERSVRTBL_MANAGER_H + + -- Gitblit v1.8.0