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/controller/VssDomainUnitTblController.h | 324 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 324 insertions(+), 0 deletions(-) diff --git a/QiaoJiaSystem/DataManagerServer/vss/controller/VssDomainUnitTblController.h b/QiaoJiaSystem/DataManagerServer/vss/controller/VssDomainUnitTblController.h new file mode 100755 index 0000000..c9674ab --- /dev/null +++ b/QiaoJiaSystem/DataManagerServer/vss/controller/VssDomainUnitTblController.h @@ -0,0 +1,324 @@ +#ifndef VSSDOMAINUNITTBL_CONTROLLER_H +#define VSSDOMAINUNITTBL_CONTROLLER_H + +#include <string> +#include <DataManagerServer/http_configserver.h> +#include "vss/dao/VssDomainUnitTblDao.h" +#include "vss/model/VssDomainUnitTblBuilder.h" +#include "vss/model/VssDomainUnitTbl.h" +#include "VssBaseController.h" +#include <mysql++.h> + +using namespace std; + +/** + * 鍒涘缓涓�绾ц澶囪〃 + */ +class VssDomainUnitTblController : public VssBaseController { +private: + /** 鍒涘缓涓�绾ц澶囪〃鏋勯�犲嚱鏁� */ + VssDomainUnitTblController() {} +public: + /** 鍒涘缓涓�绾ц澶囪〃鍗曚緥妯″紡 */ + static VssDomainUnitTblController* instance() { + static VssDomainUnitTblController instance; + return &instance; + } +public: + /** 娉ㄥ唽{label}http鏈嶅姟 */ + void registerHttpServices(HttpSrvRetRecieve& _HttpSrvRetRecieve) { + + _HttpSrvRetRecieve.setInfo("^/addVssDomainUnitTbl$", "POST", + std::bind(&VssDomainUnitTblController::addVssDomainUnitTbl, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4)); + + _HttpSrvRetRecieve.setInfo("^/delVssDomainUnitTbl$", "POST", + std::bind(&VssDomainUnitTblController::delVssDomainUnitTbl, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4)); + + _HttpSrvRetRecieve.setInfo("^/updateVssDomainUnitTbl$", "POST", + std::bind(&VssDomainUnitTblController::updateVssDomainUnitTbl, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4)); + + _HttpSrvRetRecieve.setInfo("^/findVssDomainUnitTbl$", "POST", + std::bind(&VssDomainUnitTblController::findVssDomainUnitTbl, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4)); + + _HttpSrvRetRecieve.setInfo("^/findVssDomainUnitTblList$", "POST", + std::bind(&VssDomainUnitTblController::findVssDomainUnitTblList, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, std::placeholders::_4)); + + } +public: + /** 娣诲姞鍒涘缓涓�绾ц澶囪〃 */ + std::string addVssDomainUnitTbl(std::string ip, unsigned int port, std::string content, PResponse &response) { + Json::Reader requestJsonReader; + Json::Value requestJsonValue; + Json::Value responseJsonValue; + responseJsonValue["message"] = "娣诲姞澶辫触锛�"; + responseJsonValue["success"] = "false"; + if (requestJsonReader.parse(content, requestJsonValue)) { + VssDomainUnitTblBuilder vssDomainUnitTblBuilder; + + Json::Value iDJsonValue = requestJsonValue[VssDomainUnitTbl_ID]; + if (iDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addID(std::stoi((iDJsonValue.asString()))); + } + + Json::Value devPubIDJsonValue = requestJsonValue[VssDomainUnitTbl_DevPubID]; + if (devPubIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDevPubID((devPubIDJsonValue.asString())); + } + + Json::Value domainPubIDJsonValue = requestJsonValue[VssDomainUnitTbl_DomainPubID]; + if (domainPubIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDomainPubID((domainPubIDJsonValue.asString())); + } + + Json::Value nameJsonValue = requestJsonValue[VssDomainUnitTbl_Name]; + if (nameJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addName((nameJsonValue.asString())); + } + + Json::Value businessGroupIDJsonValue = requestJsonValue[VssDomainUnitTbl_BusinessGroupID]; + if (businessGroupIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addBusinessGroupID((businessGroupIDJsonValue.asString())); + } + + Json::Value parentIdJsonValue = requestJsonValue[VssDomainUnitTbl_ParentId]; + if (parentIdJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addParentId((parentIdJsonValue.asString())); + } + + Json::Value domainTypeJsonValue = requestJsonValue[VssDomainUnitTbl_DomainType]; + if (domainTypeJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDomainType(std::stoi((domainTypeJsonValue.asString()))); + } + + Json::Value updateTimeJsonValue = requestJsonValue[VssDomainUnitTbl_UpdateTime]; + if (updateTimeJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addUpdateTime((updateTimeJsonValue.asString())); + } + auto keyValuesToAdd = vssDomainUnitTblBuilder.buildVssDomainUnitTblMap(); + if (keyValuesToAdd.size() > 0) { + mysqlpp::SimpleResult addVssDomainUnitTblResult = VssDomainUnitTblDao::instance()->addVssDomainUnitTbl(keyValuesToAdd); + if (addVssDomainUnitTblResult.rows() > 0) { + responseJsonValue["success"] = "true"; + responseJsonValue["message"] = "娣诲姞鎴愬姛锛�"; + } + } + } + return responseJsonValue.toStyledString(); + } + + /** 鍒犻櫎鍒涘缓涓�绾ц澶囪〃 */ + std::string delVssDomainUnitTbl(std::string ip, unsigned int port, std::string content, PResponse &response) { + Json::Reader requestJsonReader; + Json::Value requestJsonValue; + Json::Value responseJsonValue; + responseJsonValue["message"] = "鍒犻櫎澶辫触锛�"; + responseJsonValue["success"] = "false"; + if (requestJsonReader.parse(content, requestJsonValue)) { + Json::Value iDJsonValue = requestJsonValue[VssDomainUnitTbl_ID]; + if (iDJsonValue.type() != Json::ValueType::nullValue) { + string iDValue = iDJsonValue.asString(); + if (iDValue.size() > 0 && VssDomainUnitTblDao::instance()->deleteByColumn("ID", iDValue)) { + responseJsonValue["success"] = "true"; + responseJsonValue["message"] = "鍒犻櫎鎴愬姛!"; + } + } + + } + return responseJsonValue.toStyledString(); + } + + /** 鏇存柊鍒涘缓涓�绾ц澶囪〃 */ + std::string updateVssDomainUnitTbl(std::string ip, unsigned int port, std::string content, PResponse &response) { + Json::Reader requestJsonReader; + Json::Value requestJsonValue; + Json::Value responseJsonValue; + responseJsonValue["message"] = "鏇存柊澶辫触锛�"; + responseJsonValue["success"] = "false"; + if (requestJsonReader.parse(content, requestJsonValue)) { + VssDomainUnitTblBuilder vssDomainUnitTblBuilder; + + Json::Value iDJsonValue = requestJsonValue[VssDomainUnitTbl_ID]; + if (iDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addID(std::stoi((iDJsonValue.asString()))); + } + + Json::Value devPubIDJsonValue = requestJsonValue[VssDomainUnitTbl_DevPubID]; + if (devPubIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDevPubID((devPubIDJsonValue.asString())); + } + + Json::Value domainPubIDJsonValue = requestJsonValue[VssDomainUnitTbl_DomainPubID]; + if (domainPubIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDomainPubID((domainPubIDJsonValue.asString())); + } + + Json::Value nameJsonValue = requestJsonValue[VssDomainUnitTbl_Name]; + if (nameJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addName((nameJsonValue.asString())); + } + + Json::Value businessGroupIDJsonValue = requestJsonValue[VssDomainUnitTbl_BusinessGroupID]; + if (businessGroupIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addBusinessGroupID((businessGroupIDJsonValue.asString())); + } + + Json::Value parentIdJsonValue = requestJsonValue[VssDomainUnitTbl_ParentId]; + if (parentIdJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addParentId((parentIdJsonValue.asString())); + } + + Json::Value domainTypeJsonValue = requestJsonValue[VssDomainUnitTbl_DomainType]; + if (domainTypeJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDomainType(std::stoi((domainTypeJsonValue.asString()))); + } + + Json::Value updateTimeJsonValue = requestJsonValue[VssDomainUnitTbl_UpdateTime]; + if (updateTimeJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addUpdateTime((updateTimeJsonValue.asString())); + } + if (iDJsonValue.type() != Json::ValueType::nullValue) { + string iDValue = iDJsonValue.asString(); + if (iDValue.size() > 0 && VssDomainUnitTblDao::instance()->updateVssDomainUnitTbl(vssDomainUnitTblBuilder.buildVssDomainUnitTblMap(), "ID", iDValue)) { + responseJsonValue["success"] = "true"; + responseJsonValue["message"] = "鏇存柊鎴愬姛锛�"; + } + } + } + return responseJsonValue.toStyledString(); + } + + /** 鏌ユ壘鍗曚釜鍒涘缓涓�绾ц澶囪〃 */ + std::string findVssDomainUnitTbl(std::string ip, unsigned int port, std::string content, PResponse &response) { + Json::Reader requestJsonReader; + Json::Value requestJsonValue; + Json::Value responseJsonValue; + responseJsonValue["message"] = "鏌ヨ澶辫触锛�"; + responseJsonValue["success"] = "false"; + if (requestJsonReader.parse(content, requestJsonValue)) { + VssDomainUnitTblBuilder vssDomainUnitTblBuilder; + + Json::Value iDJsonValue = requestJsonValue[VssDomainUnitTbl_ID]; + if (iDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addID(std::stoi((iDJsonValue.asString()))); + } + + Json::Value devPubIDJsonValue = requestJsonValue[VssDomainUnitTbl_DevPubID]; + if (devPubIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDevPubID((devPubIDJsonValue.asString())); + } + + Json::Value domainPubIDJsonValue = requestJsonValue[VssDomainUnitTbl_DomainPubID]; + if (domainPubIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDomainPubID((domainPubIDJsonValue.asString())); + } + + Json::Value nameJsonValue = requestJsonValue[VssDomainUnitTbl_Name]; + if (nameJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addName((nameJsonValue.asString())); + } + + Json::Value businessGroupIDJsonValue = requestJsonValue[VssDomainUnitTbl_BusinessGroupID]; + if (businessGroupIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addBusinessGroupID((businessGroupIDJsonValue.asString())); + } + + Json::Value parentIdJsonValue = requestJsonValue[VssDomainUnitTbl_ParentId]; + if (parentIdJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addParentId((parentIdJsonValue.asString())); + } + + Json::Value domainTypeJsonValue = requestJsonValue[VssDomainUnitTbl_DomainType]; + if (domainTypeJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDomainType(std::stoi((domainTypeJsonValue.asString()))); + } + + Json::Value updateTimeJsonValue = requestJsonValue[VssDomainUnitTbl_UpdateTime]; + if (updateTimeJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addUpdateTime((updateTimeJsonValue.asString())); + } + responseJsonValue["message"] = "鏌ヨ鎴愬姛锛�"; + responseJsonValue["success"] = "true"; + responseJsonValue["data"] = VssDomainUnitTblDao::instance()->findJsonArray(string("select * from ") + VSSDomainUnitTbl_TABLE_NAME + " where 1 = 1 limit 1"); + } + return responseJsonValue.toStyledString(); + } + + /** 鏌ユ壘鍒涘缓涓�绾ц澶囪〃鍒楄〃 */ + std::string findVssDomainUnitTblList(std::string ip, unsigned int port, std::string content, PResponse &response) { + Json::Reader requestJsonReader; + Json::Value requestJsonValue; + Json::Value responseJsonValue; + responseJsonValue["message"] = "鏌ヨ澶辫触锛�"; + responseJsonValue["success"] = "false"; + if (content == "" || requestJsonReader.parse(content, requestJsonValue)) { + VssDomainUnitTblBuilder vssDomainUnitTblBuilder; + + Json::Value iDJsonValue = requestJsonValue[VssDomainUnitTbl_ID]; + if (iDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addID(std::stoi((iDJsonValue.asString()))); + } + + Json::Value devPubIDJsonValue = requestJsonValue[VssDomainUnitTbl_DevPubID]; + if (devPubIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDevPubID((devPubIDJsonValue.asString())); + } + + Json::Value domainPubIDJsonValue = requestJsonValue[VssDomainUnitTbl_DomainPubID]; + if (domainPubIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDomainPubID((domainPubIDJsonValue.asString())); + } + + Json::Value nameJsonValue = requestJsonValue[VssDomainUnitTbl_Name]; + if (nameJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addName((nameJsonValue.asString())); + } + + Json::Value businessGroupIDJsonValue = requestJsonValue[VssDomainUnitTbl_BusinessGroupID]; + if (businessGroupIDJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addBusinessGroupID((businessGroupIDJsonValue.asString())); + } + + Json::Value parentIdJsonValue = requestJsonValue[VssDomainUnitTbl_ParentId]; + if (parentIdJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addParentId((parentIdJsonValue.asString())); + } + + Json::Value domainTypeJsonValue = requestJsonValue[VssDomainUnitTbl_DomainType]; + if (domainTypeJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addDomainType(std::stoi((domainTypeJsonValue.asString()))); + } + + Json::Value updateTimeJsonValue = requestJsonValue[VssDomainUnitTbl_UpdateTime]; + if (updateTimeJsonValue.type() != Json::ValueType::nullValue) { + vssDomainUnitTblBuilder.addUpdateTime((updateTimeJsonValue.asString())); + } + responseJsonValue["message"] = "鏌ヨ鎴愬姛锛�"; + responseJsonValue["success"] = "true"; + responseJsonValue["data"] = VssDomainUnitTblDao::instance()->findJsonArray(string("select * from ") + VSSDomainUnitTbl_TABLE_NAME + " where 1 = 1"); + + } + return responseJsonValue.toStyledString(); + } +}; + + + + + + +#endif //VSSDOMAINUNITTBL_CONTROLLER_H + + + + + -- Gitblit v1.8.0