| | |
| | | |
| | | #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 列名;whereValue 列值 */ |
| | | 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转model类 */ |
| | | 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 |
| | | |
| | | |
| | |
|
| | | #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 列名;whereValue 列值 */
|
| | | 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转model类 */
|
| | | 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
|
| | |
|
| | |
|