| | |
| | | // 时间规则 |
| | | std::vector<protomsg::CameraTimerule> list; |
| | | if (dbapi_get_time_rules(handle, list)) { |
| | | printf("CameraTimerule:\n"); |
| | | for (unsigned int i = 0; i < list.size(); i++) { |
| | | printf("CameraTimerule: %s\n", list[i].id().c_str()); |
| | | } |
| | | } |
| | | |
| | | //系统授权信息 |
| | |
| | | return json; |
| | | } |
| | | |
| | | char *make_get_request(const char *topic, const std::map<string, string> *query_params) { |
| | | yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); |
| | | yyjson_mut_val *root = yyjson_mut_obj(doc); |
| | | yyjson_mut_obj_add_strn(doc, root, "path", topic, strlen(topic)); |
| | | yyjson_mut_obj_add_strn(doc, root, "method", "GET", 3); |
| | | |
| | | // 填充请求参数 |
| | | if (query_params != NULL) { |
| | | yyjson_mut_val *query_map = yyjson_mut_obj(doc); |
| | | |
| | | std::map<string, string> t_map = *query_params; |
| | | std::map<string, string>::iterator iter; |
| | | for (iter = t_map.begin(); iter != t_map.end(); iter++) { |
| | | yyjson_mut_val *_key = yyjson_mut_str(doc, iter->first.c_str()); |
| | | |
| | | yyjson_mut_val *param = yyjson_mut_arr(doc); |
| | | yyjson_mut_val *_val = yyjson_mut_str(doc, iter->second.c_str()); |
| | | yyjson_mut_arr_append(param, _val); |
| | | |
| | | yyjson_mut_obj_add(query_map, _key, param); |
| | | } |
| | | |
| | | yyjson_mut_val *query_map_key = yyjson_mut_str(doc, "queryMap"); |
| | | yyjson_mut_obj_add(root, query_map_key, query_map); |
| | | } |
| | | |
| | | yyjson_mut_doc_set_root(doc, root); |
| | | |
| | | size_t jsonl = 0; |
| | | char *json = yyjson_mut_val_write(root, 0, &jsonl); |
| | | |
| | | yyjson_mut_doc_free(doc); |
| | | |
| | | return json; |
| | | } |
| | | |
| | | extern "C" int bus_dbapi_get_json_data(const char *json, char **pptr_data, yyjson_type *ptr_type) { |
| | | /*{ |
| | | "success": true, |
| | |
| | | |
| | | bool json_to_proto(const std::string &json, google::protobuf::Message &message); |
| | | bool proto_to_json(const google::protobuf::Message &message, std::string &json); |
| | | |
| | | char *make_get_request(const char *topic); |
| | | char *make_get_request(const char *topic, const std::map<string, string> *query_params); |
| | | |
| | | bool bus_dbapi_get(void *handle, const char *topic, google::protobuf::Message &message); |
| | | bool bus_dbapi_get_topic_data(void *handle, const char *topic, crepmsg **pptr_repmsg, size_t len); |
| | | extern "C" int bus_dbapi_get_json_data(const char *json, char **pptr_data, uint8_t *ptr_type); |
| | | bool bus_dbapi_get_str(void *handle, const char *topic, char **pptr_str); |
| | | int get_value_by_key(char *json, const char *key, char **pptr_data); |
| | | |
| | | template <class T> |
| | | bool bus_dbapi_get_list(char *json, T &list) { |
| | | char *ptr_value = NULL; |