| | |
| | | #ifndef VSSCHANNELTBL_CONTROLLER_H |
| | | #define VSSCHANNELTBL_CONTROLLER_H |
| | | |
| | | #include <string> |
| | | #include <DataManagerServer/http_configserver.h> |
| | | #include "vss/dao/VssChannelTblDao.h" |
| | | #include "vss/model/VssChannelTblBuilder.h" |
| | | #include "vss/model/VssChannelTbl.h" |
| | | #include "VssBaseController.h" |
| | | #include <mysql++.h> |
| | | |
| | | using namespace std; |
| | | |
| | | /** |
| | | * 创建二级设备表 |
| | | */ |
| | | class VssChannelTblController : public VssBaseController { |
| | | private: |
| | | /** 创建二级设备表构造函数 */ |
| | | VssChannelTblController() {} |
| | | public: |
| | | /** 创建二级设备表单例模式 */ |
| | | static VssChannelTblController* instance() { |
| | | static VssChannelTblController instance; |
| | | return &instance; |
| | | } |
| | | public: |
| | | /** 注册{label}http服务 */ |
| | | void registerHttpServices(HttpSrvRetRecieve& _HttpSrvRetRecieve) { |
| | | |
| | | _HttpSrvRetRecieve.setInfo("^/addVssChannelTbl$", "POST", |
| | | std::bind(&VssChannelTblController::addVssChannelTbl, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | |
| | | _HttpSrvRetRecieve.setInfo("^/delVssChannelTbl$", "POST", |
| | | std::bind(&VssChannelTblController::delVssChannelTbl, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | |
| | | _HttpSrvRetRecieve.setInfo("^/updateVssChannelTbl$", "POST", |
| | | std::bind(&VssChannelTblController::updateVssChannelTbl, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | |
| | | _HttpSrvRetRecieve.setInfo("^/findVssChannelTbl$", "POST", |
| | | std::bind(&VssChannelTblController::findVssChannelTbl, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | |
| | | _HttpSrvRetRecieve.setInfo("^/findVssChannelTblList$", "POST", |
| | | std::bind(&VssChannelTblController::findVssChannelTblList, this, |
| | | std::placeholders::_1, std::placeholders::_2, |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | |
| | | } |
| | | public: |
| | | /** 添加创建二级设备表 */ |
| | | std::string addVssChannelTbl(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)) { |
| | | VssChannelTblBuilder vssChannelTblBuilder; |
| | | |
| | | Json::Value iDJsonValue = requestJsonValue[VssChannelTbl_ID]; |
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addID(iDJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value devPubIDJsonValue = requestJsonValue[VssChannelTbl_DevPubID]; |
| | | if (devPubIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDevPubID(devPubIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value nicknameJsonValue = requestJsonValue[VssChannelTbl_Nickname]; |
| | | if (nicknameJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addNickname(nicknameJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value chanPubIDJsonValue = requestJsonValue[VssChannelTbl_ChanPubID]; |
| | | if (chanPubIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addChanPubID(chanPubIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value aliveJsonValue = requestJsonValue[VssChannelTbl_Alive]; |
| | | if (aliveJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAlive(aliveJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value corpIDJsonValue = requestJsonValue[VssChannelTbl_CorpID]; |
| | | if (corpIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addCorpID(corpIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value modelJsonValue = requestJsonValue[VssChannelTbl_Model]; |
| | | if (modelJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addModel(modelJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value ownerJsonValue = requestJsonValue[VssChannelTbl_Owner]; |
| | | if (ownerJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addOwner(ownerJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value civilCodeJsonValue = requestJsonValue[VssChannelTbl_CivilCode]; |
| | | if (civilCodeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addCivilCode(civilCodeJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value addressJsonValue = requestJsonValue[VssChannelTbl_Address]; |
| | | if (addressJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAddress(addressJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value parentalJsonValue = requestJsonValue[VssChannelTbl_Parental]; |
| | | if (parentalJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addParental(parentalJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value parentIdJsonValue = requestJsonValue[VssChannelTbl_ParentId]; |
| | | if (parentIdJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addParentId(parentIdJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value iPJsonValue = requestJsonValue[VssChannelTbl_IP]; |
| | | if (iPJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addIP(iPJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value portJsonValue = requestJsonValue[VssChannelTbl_Port]; |
| | | if (portJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addPort(portJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value longitudeJsonValue = requestJsonValue[VssChannelTbl_Longitude]; |
| | | if (longitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addLongitude(longitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value latitudeJsonValue = requestJsonValue[VssChannelTbl_Latitude]; |
| | | if (latitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addLatitude(latitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value altitudeJsonValue = requestJsonValue[VssChannelTbl_Altitude]; |
| | | if (altitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAltitude(altitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value pTZTypeJsonValue = requestJsonValue[VssChannelTbl_PTZType]; |
| | | if (pTZTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addPTZType(pTZTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value roomTypeJsonValue = requestJsonValue[VssChannelTbl_RoomType]; |
| | | if (roomTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addRoomType(roomTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value directionTypeJsonValue = requestJsonValue[VssChannelTbl_DirectionType]; |
| | | if (directionTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDirectionType(directionTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value streamTypeJsonValue = requestJsonValue[VssChannelTbl_StreamType]; |
| | | if (streamTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addStreamType(streamTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value dMarkerJsonValue = requestJsonValue[VssChannelTbl_DMarker]; |
| | | if (dMarkerJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDMarker(dMarkerJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value updateTimeJsonValue = requestJsonValue[VssChannelTbl_UpdateTime]; |
| | | if (updateTimeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addUpdateTime(updateTimeJsonValue.asString()); |
| | | } |
| | | auto keyValuesToAdd = vssChannelTblBuilder.buildVssChannelTblMap(); |
| | | if (keyValuesToAdd.size() > 0) { |
| | | mysqlpp::SimpleResult addVssChannelTblResult = VssChannelTblDao::instance()->addVssChannelTbl(keyValuesToAdd); |
| | | if (addVssChannelTblResult.rows() > 0) { |
| | | responseJsonValue["success"] = "true"; |
| | | responseJsonValue["message"] = "添加成功!"; |
| | | } |
| | | } |
| | | } |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | |
| | | /** 删除创建二级设备表 */ |
| | | std::string delVssChannelTbl(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[VssChannelTbl_ID]; |
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) { |
| | | string iDValue = iDJsonValue.asString(); |
| | | if (iDValue.size() > 0 && VssChannelTblDao::instance()->deleteByColumn("ID", iDValue)) { |
| | | responseJsonValue["success"] = "true"; |
| | | responseJsonValue["message"] = "删除成功!"; |
| | | } |
| | | } |
| | | |
| | | } |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | |
| | | /** 更新创建二级设备表 */ |
| | | std::string updateVssChannelTbl(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)) { |
| | | VssChannelTblBuilder vssChannelTblBuilder; |
| | | |
| | | Json::Value iDJsonValue = requestJsonValue[VssChannelTbl_ID]; |
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addID(iDJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value devPubIDJsonValue = requestJsonValue[VssChannelTbl_DevPubID]; |
| | | if (devPubIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDevPubID(devPubIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value nicknameJsonValue = requestJsonValue[VssChannelTbl_Nickname]; |
| | | if (nicknameJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addNickname(nicknameJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value chanPubIDJsonValue = requestJsonValue[VssChannelTbl_ChanPubID]; |
| | | if (chanPubIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addChanPubID(chanPubIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value aliveJsonValue = requestJsonValue[VssChannelTbl_Alive]; |
| | | if (aliveJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAlive(aliveJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value corpIDJsonValue = requestJsonValue[VssChannelTbl_CorpID]; |
| | | if (corpIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addCorpID(corpIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value modelJsonValue = requestJsonValue[VssChannelTbl_Model]; |
| | | if (modelJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addModel(modelJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value ownerJsonValue = requestJsonValue[VssChannelTbl_Owner]; |
| | | if (ownerJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addOwner(ownerJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value civilCodeJsonValue = requestJsonValue[VssChannelTbl_CivilCode]; |
| | | if (civilCodeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addCivilCode(civilCodeJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value addressJsonValue = requestJsonValue[VssChannelTbl_Address]; |
| | | if (addressJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAddress(addressJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value parentalJsonValue = requestJsonValue[VssChannelTbl_Parental]; |
| | | if (parentalJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addParental(parentalJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value parentIdJsonValue = requestJsonValue[VssChannelTbl_ParentId]; |
| | | if (parentIdJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addParentId(parentIdJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value iPJsonValue = requestJsonValue[VssChannelTbl_IP]; |
| | | if (iPJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addIP(iPJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value portJsonValue = requestJsonValue[VssChannelTbl_Port]; |
| | | if (portJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addPort(portJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value longitudeJsonValue = requestJsonValue[VssChannelTbl_Longitude]; |
| | | if (longitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addLongitude(longitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value latitudeJsonValue = requestJsonValue[VssChannelTbl_Latitude]; |
| | | if (latitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addLatitude(latitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value altitudeJsonValue = requestJsonValue[VssChannelTbl_Altitude]; |
| | | if (altitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAltitude(altitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value pTZTypeJsonValue = requestJsonValue[VssChannelTbl_PTZType]; |
| | | if (pTZTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addPTZType(pTZTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value roomTypeJsonValue = requestJsonValue[VssChannelTbl_RoomType]; |
| | | if (roomTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addRoomType(roomTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value directionTypeJsonValue = requestJsonValue[VssChannelTbl_DirectionType]; |
| | | if (directionTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDirectionType(directionTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value streamTypeJsonValue = requestJsonValue[VssChannelTbl_StreamType]; |
| | | if (streamTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addStreamType(streamTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value dMarkerJsonValue = requestJsonValue[VssChannelTbl_DMarker]; |
| | | if (dMarkerJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDMarker(dMarkerJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value updateTimeJsonValue = requestJsonValue[VssChannelTbl_UpdateTime]; |
| | | if (updateTimeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addUpdateTime(updateTimeJsonValue.asString()); |
| | | } |
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) { |
| | | string iDValue = iDJsonValue.asString(); |
| | | if (iDValue.size() > 0 && VssChannelTblDao::instance()->updateVssChannelTbl(vssChannelTblBuilder.buildVssChannelTblMap(), "ID", iDValue)) { |
| | | responseJsonValue["success"] = "true"; |
| | | responseJsonValue["message"] = "更新成功!"; |
| | | } |
| | | } |
| | | } |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | |
| | | /** 查找单个创建二级设备表 */ |
| | | std::string findVssChannelTbl(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)) { |
| | | VssChannelTblBuilder vssChannelTblBuilder; |
| | | |
| | | Json::Value iDJsonValue = requestJsonValue[VssChannelTbl_ID]; |
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addID(iDJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value devPubIDJsonValue = requestJsonValue[VssChannelTbl_DevPubID]; |
| | | if (devPubIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDevPubID(devPubIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value nicknameJsonValue = requestJsonValue[VssChannelTbl_Nickname]; |
| | | if (nicknameJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addNickname(nicknameJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value chanPubIDJsonValue = requestJsonValue[VssChannelTbl_ChanPubID]; |
| | | if (chanPubIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addChanPubID(chanPubIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value aliveJsonValue = requestJsonValue[VssChannelTbl_Alive]; |
| | | if (aliveJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAlive(aliveJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value corpIDJsonValue = requestJsonValue[VssChannelTbl_CorpID]; |
| | | if (corpIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addCorpID(corpIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value modelJsonValue = requestJsonValue[VssChannelTbl_Model]; |
| | | if (modelJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addModel(modelJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value ownerJsonValue = requestJsonValue[VssChannelTbl_Owner]; |
| | | if (ownerJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addOwner(ownerJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value civilCodeJsonValue = requestJsonValue[VssChannelTbl_CivilCode]; |
| | | if (civilCodeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addCivilCode(civilCodeJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value addressJsonValue = requestJsonValue[VssChannelTbl_Address]; |
| | | if (addressJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAddress(addressJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value parentalJsonValue = requestJsonValue[VssChannelTbl_Parental]; |
| | | if (parentalJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addParental(parentalJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value parentIdJsonValue = requestJsonValue[VssChannelTbl_ParentId]; |
| | | if (parentIdJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addParentId(parentIdJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value iPJsonValue = requestJsonValue[VssChannelTbl_IP]; |
| | | if (iPJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addIP(iPJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value portJsonValue = requestJsonValue[VssChannelTbl_Port]; |
| | | if (portJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addPort(portJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value longitudeJsonValue = requestJsonValue[VssChannelTbl_Longitude]; |
| | | if (longitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addLongitude(longitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value latitudeJsonValue = requestJsonValue[VssChannelTbl_Latitude]; |
| | | if (latitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addLatitude(latitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value altitudeJsonValue = requestJsonValue[VssChannelTbl_Altitude]; |
| | | if (altitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAltitude(altitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value pTZTypeJsonValue = requestJsonValue[VssChannelTbl_PTZType]; |
| | | if (pTZTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addPTZType(pTZTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value roomTypeJsonValue = requestJsonValue[VssChannelTbl_RoomType]; |
| | | if (roomTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addRoomType(roomTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value directionTypeJsonValue = requestJsonValue[VssChannelTbl_DirectionType]; |
| | | if (directionTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDirectionType(directionTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value streamTypeJsonValue = requestJsonValue[VssChannelTbl_StreamType]; |
| | | if (streamTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addStreamType(streamTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value dMarkerJsonValue = requestJsonValue[VssChannelTbl_DMarker]; |
| | | if (dMarkerJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDMarker(dMarkerJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value updateTimeJsonValue = requestJsonValue[VssChannelTbl_UpdateTime]; |
| | | if (updateTimeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addUpdateTime(updateTimeJsonValue.asString()); |
| | | } |
| | | responseJsonValue["message"] = "查询成功!"; |
| | | responseJsonValue["success"] = "true"; |
| | | responseJsonValue["data"] = VssChannelTblDao::instance()->findJsonArray(string("select * from ") + VSSChannelTbl_TABLE_NAME + " where 1 = 1 limit 1"); |
| | | } |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | |
| | | /** 查找创建二级设备表列表 */ |
| | | std::string findVssChannelTblList(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)) { |
| | | VssChannelTblBuilder vssChannelTblBuilder; |
| | | |
| | | Json::Value iDJsonValue = requestJsonValue[VssChannelTbl_ID]; |
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addID(iDJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value devPubIDJsonValue = requestJsonValue[VssChannelTbl_DevPubID]; |
| | | if (devPubIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDevPubID(devPubIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value nicknameJsonValue = requestJsonValue[VssChannelTbl_Nickname]; |
| | | if (nicknameJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addNickname(nicknameJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value chanPubIDJsonValue = requestJsonValue[VssChannelTbl_ChanPubID]; |
| | | if (chanPubIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addChanPubID(chanPubIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value aliveJsonValue = requestJsonValue[VssChannelTbl_Alive]; |
| | | if (aliveJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAlive(aliveJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value corpIDJsonValue = requestJsonValue[VssChannelTbl_CorpID]; |
| | | if (corpIDJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addCorpID(corpIDJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value modelJsonValue = requestJsonValue[VssChannelTbl_Model]; |
| | | if (modelJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addModel(modelJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value ownerJsonValue = requestJsonValue[VssChannelTbl_Owner]; |
| | | if (ownerJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addOwner(ownerJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value civilCodeJsonValue = requestJsonValue[VssChannelTbl_CivilCode]; |
| | | if (civilCodeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addCivilCode(civilCodeJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value addressJsonValue = requestJsonValue[VssChannelTbl_Address]; |
| | | if (addressJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAddress(addressJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value parentalJsonValue = requestJsonValue[VssChannelTbl_Parental]; |
| | | if (parentalJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addParental(parentalJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value parentIdJsonValue = requestJsonValue[VssChannelTbl_ParentId]; |
| | | if (parentIdJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addParentId(parentIdJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value iPJsonValue = requestJsonValue[VssChannelTbl_IP]; |
| | | if (iPJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addIP(iPJsonValue.asString()); |
| | | } |
| | | |
| | | Json::Value portJsonValue = requestJsonValue[VssChannelTbl_Port]; |
| | | if (portJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addPort(portJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value longitudeJsonValue = requestJsonValue[VssChannelTbl_Longitude]; |
| | | if (longitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addLongitude(longitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value latitudeJsonValue = requestJsonValue[VssChannelTbl_Latitude]; |
| | | if (latitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addLatitude(latitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value altitudeJsonValue = requestJsonValue[VssChannelTbl_Altitude]; |
| | | if (altitudeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addAltitude(altitudeJsonValue.asDouble()); |
| | | } |
| | | |
| | | Json::Value pTZTypeJsonValue = requestJsonValue[VssChannelTbl_PTZType]; |
| | | if (pTZTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addPTZType(pTZTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value roomTypeJsonValue = requestJsonValue[VssChannelTbl_RoomType]; |
| | | if (roomTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addRoomType(roomTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value directionTypeJsonValue = requestJsonValue[VssChannelTbl_DirectionType]; |
| | | if (directionTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDirectionType(directionTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value streamTypeJsonValue = requestJsonValue[VssChannelTbl_StreamType]; |
| | | if (streamTypeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addStreamType(streamTypeJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value dMarkerJsonValue = requestJsonValue[VssChannelTbl_DMarker]; |
| | | if (dMarkerJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addDMarker(dMarkerJsonValue.asInt()); |
| | | } |
| | | |
| | | Json::Value updateTimeJsonValue = requestJsonValue[VssChannelTbl_UpdateTime]; |
| | | if (updateTimeJsonValue.type() != Json::ValueType::nullValue) { |
| | | vssChannelTblBuilder.addUpdateTime(updateTimeJsonValue.asString()); |
| | | } |
| | | responseJsonValue["message"] = "查询成功!"; |
| | | responseJsonValue["success"] = "true"; |
| | | responseJsonValue["data"] = VssChannelTblDao::instance()->findJsonArray(string("select * from ") + VSSChannelTbl_TABLE_NAME + " where 1 = 1"); |
| | | |
| | | } |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #endif //VSSCHANNELTBL_CONTROLLER_H |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #ifndef VSSCHANNELTBL_CONTROLLER_H
|
| | | #define VSSCHANNELTBL_CONTROLLER_H
|
| | |
|
| | | #include <string>
|
| | | #include <DataManagerServer/http_configserver.h>
|
| | | #include "vss/dao/VssChannelTblDao.h"
|
| | | #include "vss/model/VssChannelTblBuilder.h"
|
| | | #include "vss/model/VssChannelTbl.h"
|
| | | #include "VssBaseController.h"
|
| | | #include <mysql++.h>
|
| | |
|
| | | using namespace std;
|
| | |
|
| | | /**
|
| | | * 创建二级设备表
|
| | | */
|
| | | class VssChannelTblController : public VssBaseController {
|
| | | private:
|
| | | /** 创建二级设备表构造函数 */
|
| | | VssChannelTblController() {}
|
| | | public:
|
| | | /** 创建二级设备表单例模式 */
|
| | | static VssChannelTblController* instance() {
|
| | | static VssChannelTblController instance;
|
| | | return &instance;
|
| | | }
|
| | | public:
|
| | | /** 注册{label}http服务 */
|
| | | void registerHttpServices(HttpSrvRetRecieve& _HttpSrvRetRecieve) {
|
| | |
|
| | | _HttpSrvRetRecieve.setInfo("^/addVssChannelTbl$", "POST",
|
| | | std::bind(&VssChannelTblController::addVssChannelTbl, this,
|
| | | std::placeholders::_1, std::placeholders::_2,
|
| | | std::placeholders::_3, std::placeholders::_4));
|
| | |
|
| | | _HttpSrvRetRecieve.setInfo("^/delVssChannelTbl$", "POST",
|
| | | std::bind(&VssChannelTblController::delVssChannelTbl, this,
|
| | | std::placeholders::_1, std::placeholders::_2,
|
| | | std::placeholders::_3, std::placeholders::_4));
|
| | |
|
| | | _HttpSrvRetRecieve.setInfo("^/updateVssChannelTbl$", "POST",
|
| | | std::bind(&VssChannelTblController::updateVssChannelTbl, this,
|
| | | std::placeholders::_1, std::placeholders::_2,
|
| | | std::placeholders::_3, std::placeholders::_4));
|
| | |
|
| | | _HttpSrvRetRecieve.setInfo("^/findVssChannelTbl$", "POST",
|
| | | std::bind(&VssChannelTblController::findVssChannelTbl, this,
|
| | | std::placeholders::_1, std::placeholders::_2,
|
| | | std::placeholders::_3, std::placeholders::_4));
|
| | |
|
| | | _HttpSrvRetRecieve.setInfo("^/findVssChannelTblList$", "POST",
|
| | | std::bind(&VssChannelTblController::findVssChannelTblList, this,
|
| | | std::placeholders::_1, std::placeholders::_2,
|
| | | std::placeholders::_3, std::placeholders::_4));
|
| | |
|
| | | }
|
| | | public:
|
| | | /** 添加创建二级设备表 */
|
| | | std::string addVssChannelTbl(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)) {
|
| | | VssChannelTblBuilder vssChannelTblBuilder;
|
| | |
|
| | | Json::Value iDJsonValue = requestJsonValue[VssChannelTbl_ID];
|
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addID(std::stoi((iDJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value devPubIDJsonValue = requestJsonValue[VssChannelTbl_DevPubID];
|
| | | if (devPubIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDevPubID((devPubIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value nicknameJsonValue = requestJsonValue[VssChannelTbl_Nickname];
|
| | | if (nicknameJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addNickname((nicknameJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value chanPubIDJsonValue = requestJsonValue[VssChannelTbl_ChanPubID];
|
| | | if (chanPubIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addChanPubID((chanPubIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value aliveJsonValue = requestJsonValue[VssChannelTbl_Alive];
|
| | | if (aliveJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAlive(std::stoi((aliveJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value corpIDJsonValue = requestJsonValue[VssChannelTbl_CorpID];
|
| | | if (corpIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addCorpID((corpIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value modelJsonValue = requestJsonValue[VssChannelTbl_Model];
|
| | | if (modelJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addModel((modelJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value ownerJsonValue = requestJsonValue[VssChannelTbl_Owner];
|
| | | if (ownerJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addOwner((ownerJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value civilCodeJsonValue = requestJsonValue[VssChannelTbl_CivilCode];
|
| | | if (civilCodeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addCivilCode((civilCodeJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value addressJsonValue = requestJsonValue[VssChannelTbl_Address];
|
| | | if (addressJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAddress((addressJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value parentalJsonValue = requestJsonValue[VssChannelTbl_Parental];
|
| | | if (parentalJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addParental(std::stoi((parentalJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value parentIdJsonValue = requestJsonValue[VssChannelTbl_ParentId];
|
| | | if (parentIdJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addParentId((parentIdJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value iPJsonValue = requestJsonValue[VssChannelTbl_IP];
|
| | | if (iPJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addIP((iPJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value portJsonValue = requestJsonValue[VssChannelTbl_Port];
|
| | | if (portJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addPort(std::stoi((portJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value longitudeJsonValue = requestJsonValue[VssChannelTbl_Longitude];
|
| | | if (longitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addLongitude(std::stod((longitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value latitudeJsonValue = requestJsonValue[VssChannelTbl_Latitude];
|
| | | if (latitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addLatitude(std::stod((latitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value altitudeJsonValue = requestJsonValue[VssChannelTbl_Altitude];
|
| | | if (altitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAltitude(std::stod((altitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value pTZTypeJsonValue = requestJsonValue[VssChannelTbl_PTZType];
|
| | | if (pTZTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addPTZType(std::stoi((pTZTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value roomTypeJsonValue = requestJsonValue[VssChannelTbl_RoomType];
|
| | | if (roomTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addRoomType(std::stoi((roomTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value directionTypeJsonValue = requestJsonValue[VssChannelTbl_DirectionType];
|
| | | if (directionTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDirectionType(std::stoi((directionTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value streamTypeJsonValue = requestJsonValue[VssChannelTbl_StreamType];
|
| | | if (streamTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addStreamType(std::stoi((streamTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value dMarkerJsonValue = requestJsonValue[VssChannelTbl_DMarker];
|
| | | if (dMarkerJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDMarker(std::stoi((dMarkerJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value updateTimeJsonValue = requestJsonValue[VssChannelTbl_UpdateTime];
|
| | | if (updateTimeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addUpdateTime((updateTimeJsonValue.asString()));
|
| | | }
|
| | | auto keyValuesToAdd = vssChannelTblBuilder.buildVssChannelTblMap();
|
| | | if (keyValuesToAdd.size() > 0) {
|
| | | mysqlpp::SimpleResult addVssChannelTblResult = VssChannelTblDao::instance()->addVssChannelTbl(keyValuesToAdd);
|
| | | if (addVssChannelTblResult.rows() > 0) {
|
| | | responseJsonValue["success"] = "true";
|
| | | responseJsonValue["message"] = "添加成功!";
|
| | | }
|
| | | }
|
| | | }
|
| | | return responseJsonValue.toStyledString();
|
| | | }
|
| | |
|
| | | /** 删除创建二级设备表 */
|
| | | std::string delVssChannelTbl(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[VssChannelTbl_ID];
|
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | string iDValue = iDJsonValue.asString();
|
| | | if (iDValue.size() > 0 && VssChannelTblDao::instance()->deleteByColumn("ID", iDValue)) {
|
| | | responseJsonValue["success"] = "true";
|
| | | responseJsonValue["message"] = "删除成功!";
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | return responseJsonValue.toStyledString();
|
| | | }
|
| | |
|
| | | /** 更新创建二级设备表 */
|
| | | std::string updateVssChannelTbl(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)) {
|
| | | VssChannelTblBuilder vssChannelTblBuilder;
|
| | |
|
| | | Json::Value iDJsonValue = requestJsonValue[VssChannelTbl_ID];
|
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addID(std::stoi((iDJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value devPubIDJsonValue = requestJsonValue[VssChannelTbl_DevPubID];
|
| | | if (devPubIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDevPubID((devPubIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value nicknameJsonValue = requestJsonValue[VssChannelTbl_Nickname];
|
| | | if (nicknameJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addNickname((nicknameJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value chanPubIDJsonValue = requestJsonValue[VssChannelTbl_ChanPubID];
|
| | | if (chanPubIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addChanPubID((chanPubIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value aliveJsonValue = requestJsonValue[VssChannelTbl_Alive];
|
| | | if (aliveJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAlive(std::stoi((aliveJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value corpIDJsonValue = requestJsonValue[VssChannelTbl_CorpID];
|
| | | if (corpIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addCorpID((corpIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value modelJsonValue = requestJsonValue[VssChannelTbl_Model];
|
| | | if (modelJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addModel((modelJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value ownerJsonValue = requestJsonValue[VssChannelTbl_Owner];
|
| | | if (ownerJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addOwner((ownerJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value civilCodeJsonValue = requestJsonValue[VssChannelTbl_CivilCode];
|
| | | if (civilCodeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addCivilCode((civilCodeJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value addressJsonValue = requestJsonValue[VssChannelTbl_Address];
|
| | | if (addressJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAddress((addressJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value parentalJsonValue = requestJsonValue[VssChannelTbl_Parental];
|
| | | if (parentalJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addParental(std::stoi((parentalJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value parentIdJsonValue = requestJsonValue[VssChannelTbl_ParentId];
|
| | | if (parentIdJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addParentId((parentIdJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value iPJsonValue = requestJsonValue[VssChannelTbl_IP];
|
| | | if (iPJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addIP((iPJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value portJsonValue = requestJsonValue[VssChannelTbl_Port];
|
| | | if (portJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addPort(std::stoi((portJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value longitudeJsonValue = requestJsonValue[VssChannelTbl_Longitude];
|
| | | if (longitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addLongitude(std::stod((longitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value latitudeJsonValue = requestJsonValue[VssChannelTbl_Latitude];
|
| | | if (latitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addLatitude(std::stod((latitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value altitudeJsonValue = requestJsonValue[VssChannelTbl_Altitude];
|
| | | if (altitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAltitude(std::stod((altitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value pTZTypeJsonValue = requestJsonValue[VssChannelTbl_PTZType];
|
| | | if (pTZTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addPTZType(std::stoi((pTZTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value roomTypeJsonValue = requestJsonValue[VssChannelTbl_RoomType];
|
| | | if (roomTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addRoomType(std::stoi((roomTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value directionTypeJsonValue = requestJsonValue[VssChannelTbl_DirectionType];
|
| | | if (directionTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDirectionType(std::stoi((directionTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value streamTypeJsonValue = requestJsonValue[VssChannelTbl_StreamType];
|
| | | if (streamTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addStreamType(std::stoi((streamTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value dMarkerJsonValue = requestJsonValue[VssChannelTbl_DMarker];
|
| | | if (dMarkerJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDMarker(std::stoi((dMarkerJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value updateTimeJsonValue = requestJsonValue[VssChannelTbl_UpdateTime];
|
| | | if (updateTimeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addUpdateTime((updateTimeJsonValue.asString()));
|
| | | }
|
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | string iDValue = iDJsonValue.asString();
|
| | | if (iDValue.size() > 0 && VssChannelTblDao::instance()->updateVssChannelTbl(vssChannelTblBuilder.buildVssChannelTblMap(), "ID", iDValue)) {
|
| | | responseJsonValue["success"] = "true";
|
| | | responseJsonValue["message"] = "更新成功!";
|
| | | }
|
| | | }
|
| | | }
|
| | | return responseJsonValue.toStyledString();
|
| | | }
|
| | |
|
| | | /** 查找单个创建二级设备表 */
|
| | | std::string findVssChannelTbl(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)) {
|
| | | VssChannelTblBuilder vssChannelTblBuilder;
|
| | |
|
| | | Json::Value iDJsonValue = requestJsonValue[VssChannelTbl_ID];
|
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addID(std::stoi((iDJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value devPubIDJsonValue = requestJsonValue[VssChannelTbl_DevPubID];
|
| | | if (devPubIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDevPubID((devPubIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value nicknameJsonValue = requestJsonValue[VssChannelTbl_Nickname];
|
| | | if (nicknameJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addNickname((nicknameJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value chanPubIDJsonValue = requestJsonValue[VssChannelTbl_ChanPubID];
|
| | | if (chanPubIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addChanPubID((chanPubIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value aliveJsonValue = requestJsonValue[VssChannelTbl_Alive];
|
| | | if (aliveJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAlive(std::stoi((aliveJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value corpIDJsonValue = requestJsonValue[VssChannelTbl_CorpID];
|
| | | if (corpIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addCorpID((corpIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value modelJsonValue = requestJsonValue[VssChannelTbl_Model];
|
| | | if (modelJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addModel((modelJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value ownerJsonValue = requestJsonValue[VssChannelTbl_Owner];
|
| | | if (ownerJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addOwner((ownerJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value civilCodeJsonValue = requestJsonValue[VssChannelTbl_CivilCode];
|
| | | if (civilCodeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addCivilCode((civilCodeJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value addressJsonValue = requestJsonValue[VssChannelTbl_Address];
|
| | | if (addressJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAddress((addressJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value parentalJsonValue = requestJsonValue[VssChannelTbl_Parental];
|
| | | if (parentalJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addParental(std::stoi((parentalJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value parentIdJsonValue = requestJsonValue[VssChannelTbl_ParentId];
|
| | | if (parentIdJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addParentId((parentIdJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value iPJsonValue = requestJsonValue[VssChannelTbl_IP];
|
| | | if (iPJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addIP((iPJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value portJsonValue = requestJsonValue[VssChannelTbl_Port];
|
| | | if (portJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addPort(std::stoi((portJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value longitudeJsonValue = requestJsonValue[VssChannelTbl_Longitude];
|
| | | if (longitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addLongitude(std::stod((longitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value latitudeJsonValue = requestJsonValue[VssChannelTbl_Latitude];
|
| | | if (latitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addLatitude(std::stod((latitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value altitudeJsonValue = requestJsonValue[VssChannelTbl_Altitude];
|
| | | if (altitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAltitude(std::stod((altitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value pTZTypeJsonValue = requestJsonValue[VssChannelTbl_PTZType];
|
| | | if (pTZTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addPTZType(std::stoi((pTZTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value roomTypeJsonValue = requestJsonValue[VssChannelTbl_RoomType];
|
| | | if (roomTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addRoomType(std::stoi((roomTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value directionTypeJsonValue = requestJsonValue[VssChannelTbl_DirectionType];
|
| | | if (directionTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDirectionType(std::stoi((directionTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value streamTypeJsonValue = requestJsonValue[VssChannelTbl_StreamType];
|
| | | if (streamTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addStreamType(std::stoi((streamTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value dMarkerJsonValue = requestJsonValue[VssChannelTbl_DMarker];
|
| | | if (dMarkerJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDMarker(std::stoi((dMarkerJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value updateTimeJsonValue = requestJsonValue[VssChannelTbl_UpdateTime];
|
| | | if (updateTimeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addUpdateTime((updateTimeJsonValue.asString()));
|
| | | }
|
| | | responseJsonValue["message"] = "查询成功!";
|
| | | responseJsonValue["success"] = "true";
|
| | | responseJsonValue["data"] = VssChannelTblDao::instance()->findJsonArray(string("select * from ") + VSSChannelTbl_TABLE_NAME + " where 1 = 1 limit 1", vssChannelTblBuilder.buildVssChannelTblMap());
|
| | | }
|
| | | return responseJsonValue.toStyledString();
|
| | | }
|
| | |
|
| | | /** 查找创建二级设备表列表 */
|
| | | std::string findVssChannelTblList(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)) {
|
| | | VssChannelTblBuilder vssChannelTblBuilder;
|
| | |
|
| | | Json::Value iDJsonValue = requestJsonValue[VssChannelTbl_ID];
|
| | | if (iDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addID(std::stoi((iDJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value devPubIDJsonValue = requestJsonValue[VssChannelTbl_DevPubID];
|
| | | if (devPubIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDevPubID((devPubIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value nicknameJsonValue = requestJsonValue[VssChannelTbl_Nickname];
|
| | | if (nicknameJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addNickname((nicknameJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value chanPubIDJsonValue = requestJsonValue[VssChannelTbl_ChanPubID];
|
| | | if (chanPubIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addChanPubID((chanPubIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value aliveJsonValue = requestJsonValue[VssChannelTbl_Alive];
|
| | | if (aliveJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAlive(std::stoi((aliveJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value corpIDJsonValue = requestJsonValue[VssChannelTbl_CorpID];
|
| | | if (corpIDJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addCorpID((corpIDJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value modelJsonValue = requestJsonValue[VssChannelTbl_Model];
|
| | | if (modelJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addModel((modelJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value ownerJsonValue = requestJsonValue[VssChannelTbl_Owner];
|
| | | if (ownerJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addOwner((ownerJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value civilCodeJsonValue = requestJsonValue[VssChannelTbl_CivilCode];
|
| | | if (civilCodeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addCivilCode((civilCodeJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value addressJsonValue = requestJsonValue[VssChannelTbl_Address];
|
| | | if (addressJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAddress((addressJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value parentalJsonValue = requestJsonValue[VssChannelTbl_Parental];
|
| | | if (parentalJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addParental(std::stoi((parentalJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value parentIdJsonValue = requestJsonValue[VssChannelTbl_ParentId];
|
| | | if (parentIdJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addParentId((parentIdJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value iPJsonValue = requestJsonValue[VssChannelTbl_IP];
|
| | | if (iPJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addIP((iPJsonValue.asString()));
|
| | | }
|
| | |
|
| | | Json::Value portJsonValue = requestJsonValue[VssChannelTbl_Port];
|
| | | if (portJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addPort(std::stoi((portJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value longitudeJsonValue = requestJsonValue[VssChannelTbl_Longitude];
|
| | | if (longitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addLongitude(std::stod((longitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value latitudeJsonValue = requestJsonValue[VssChannelTbl_Latitude];
|
| | | if (latitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addLatitude(std::stod((latitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value altitudeJsonValue = requestJsonValue[VssChannelTbl_Altitude];
|
| | | if (altitudeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addAltitude(std::stod((altitudeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value pTZTypeJsonValue = requestJsonValue[VssChannelTbl_PTZType];
|
| | | if (pTZTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addPTZType(std::stoi((pTZTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value roomTypeJsonValue = requestJsonValue[VssChannelTbl_RoomType];
|
| | | if (roomTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addRoomType(std::stoi((roomTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value directionTypeJsonValue = requestJsonValue[VssChannelTbl_DirectionType];
|
| | | if (directionTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDirectionType(std::stoi((directionTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value streamTypeJsonValue = requestJsonValue[VssChannelTbl_StreamType];
|
| | | if (streamTypeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addStreamType(std::stoi((streamTypeJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value dMarkerJsonValue = requestJsonValue[VssChannelTbl_DMarker];
|
| | | if (dMarkerJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addDMarker(std::stoi((dMarkerJsonValue.asString())));
|
| | | }
|
| | |
|
| | | Json::Value updateTimeJsonValue = requestJsonValue[VssChannelTbl_UpdateTime];
|
| | | if (updateTimeJsonValue.type() != Json::ValueType::nullValue) {
|
| | | vssChannelTblBuilder.addUpdateTime((updateTimeJsonValue.asString()));
|
| | | }
|
| | | responseJsonValue["message"] = "查询成功!";
|
| | | responseJsonValue["success"] = "true";
|
| | | responseJsonValue["data"] = VssChannelTblDao::instance()->findJsonArray(string("select * from ") +
|
| | | VSSChannelTbl_TABLE_NAME + " where 1 = 1"
|
| | | , vssChannelTblBuilder.buildVssChannelTblMap());
|
| | |
|
| | | }
|
| | | return responseJsonValue.toStyledString();
|
| | | }
|
| | | };
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | #endif //VSSCHANNELTBL_CONTROLLER_H
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|