| | |
| | | private: |
| | | /** 摄像头设备构造函数 */ |
| | | CamDevController() {} |
| | | |
| | | public: |
| | | /** 摄像头设备单例模式 */ |
| | | static CamDevController* instance() { |
| | | static CamDevController *instance() { |
| | | static CamDevController instance; |
| | | return &instance; |
| | | } |
| | | |
| | | public: |
| | | /** 注册{label}http服务 */ |
| | | void registerHttpServices(HttpSrvRetRecieve& _HttpSrvRetRecieve) { |
| | | void registerHttpServices(HttpSrvRetRecieve &_HttpSrvRetRecieve) { |
| | | |
| | | _HttpSrvRetRecieve.setInfo("^/addCamDev$", "POST", |
| | | std::bind(&CamDevController::addCamDev, this, |
| | |
| | | std::placeholders::_3, std::placeholders::_4)); |
| | | |
| | | } |
| | | |
| | | public: |
| | | /** 添加摄像头设备 */ |
| | | std::string addCamDev(std::string ip, unsigned int port, std::string content, PResponse &response) { |
| | |
| | | Json::Value idJsonValue = requestJsonValue[CamDev_id]; |
| | | if (idJsonValue.type() != Json::ValueType::nullValue) { |
| | | camDevBuilder.addid(std::stoi((idJsonValue.asString()))); |
| | | } else { |
| | | ERR("CamDev_id is null " << " is null"); |
| | | // return responseJsonValue.toStyledString(); |
| | | } |
| | | |
| | | Json::Value cam_dev_idJsonValue = requestJsonValue[CamDev_cam_dev_id]; |
| | | if (cam_dev_idJsonValue.type() != Json::ValueType::nullValue) { |
| | | camDevBuilder.addcam_dev_id((cam_dev_idJsonValue.asString())); |
| | | } else { |
| | | ERR(CamDev_cam_dev_id << " is null"); |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | |
| | | Json::Value nameJsonValue = requestJsonValue[CamDev_name]; |
| | |
| | | camDevBuilder.addtype((typeJsonValue.asString())); |
| | | } |
| | | if (idJsonValue.type() != Json::ValueType::nullValue) { |
| | | responseJsonValue = CamDevSqliteDao::instance()->updateCamDev(camDevBuilder.buildCamDevMap(), "id", idJsonValue.asString()); |
| | | responseJsonValue = CamDevSqliteDao::instance()->updateCamDev(camDevBuilder.buildCamDevMap(), "id", |
| | | idJsonValue.asString()); |
| | | } |
| | | } |
| | | return responseJsonValue.toStyledString(); |
| | |
| | | return responseJsonValue.toStyledString(); |
| | | } |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | #endif //CAMDEV_CONTROLLER_H |