HTTP_Definition.h 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615
  1. #ifndef __MAS_HTTP_DEFINITION_H
  2. #define __MAS_HTTP_DEFINITION_H
  3. #include "MAS_AlgoDef.h"
  4. #include "TZJson.h"
  5. NAMESPACE_MAS_BEGIN
  6. // HTTPURL
  7. // GET
  8. #define URL_GET_DB_VERSION "/mas/query/dbversion"
  9. #define URL_GET_USE_INFO "/mas/query/users"
  10. #define URL_GET_SYS_CONFIG "/mas/query/sysconfig"
  11. #define URL_GET_MEDIA_RSC_INFO "/mas/query/mediarscs"
  12. #define URL_GET_PLAN_INFO "/mas/query/plan"
  13. #define URL_GET_SERVICE_VERSION "/mas/query/serviceVersion"
  14. #define URL_GET_WABC_FILE_DOWNLOAD "/mas/download"
  15. // POST
  16. #define URL_POST_USE_INFO_COND "/mas/query/users/condition"
  17. #define URL_POST_MEDIA_SRC_INFO "/mas/query/mediasrcs"
  18. #define URL_POST_DETECTOR_INFO "/mas/query/detectors"
  19. #define URL_POST_STRATEGY_INFO "/mas/query/strategies"
  20. #define URL_POST_SCENE_INFO "/mas/query/scenes"
  21. #define URL_POST_SCENE_GROUP_INFO "/mas/query/scenegroups"
  22. #define URL_POST_ADD_USER "/mas/add/user"
  23. #define URL_POST_UPDATE_USER "/mas/update/user"
  24. #define URL_POST_DELETE_USER "/mas/delete/user"
  25. #define URL_POST_EDIT_SYS_CONFIG "/mas/edit/sysconfig"
  26. #define URL_POST_SYS_CONFIG_KEY "/mas/query/sysconfig/key"
  27. #define URL_POST_SYS_CONFIG_GROUP "/mas/query/sysconfig/group"
  28. #define URL_POST_ADD_MEDIA_SRC "/mas/add/mediasrc"
  29. #define URL_POST_DELETE_MEDIA_SRC "/mas/delete/mediasrc"
  30. #define URL_POST_EDIT_MEDIA_RSC "/mas/edit/mediarsc"
  31. #define URL_POST_ADD_MEDIA_RSC "/mas/add/mediarsc"
  32. #define URL_POST_DELETE_MEDIA_RSC "/mas/delete/mediarsc"
  33. #define URL_POST_EDIT_DETECTOR_INIT "/mas/edit/detector/initParam"
  34. #define URL_POST_EDIT_STRAGETY "/mas/edit/strategy"
  35. #define URL_POST_ADD_SCENE "/mas/add/scene"
  36. #define URL_POST_EDIT_SCENE "/mas/edit/scene"
  37. #define URL_POST_DELETE_SCENE "/mas/delete/scene"
  38. #define URL_POST_SUB_SCENE_DRAW "/mas/subscribe/scene"
  39. #define URL_POST_ADD_SCENE_GROUP "/mas/add/scenegroup"
  40. #define URL_POST_EDIT_SCENE_GROUP "/mas/edit/scenegroup"
  41. #define URL_POST_DELETE_SCENE_GROUP "/mas/delete/scenegroup"
  42. #define URL_POST_ADD_PLAN "/mas/add/plan"
  43. #define URL_POST_DELETE_PLAN "/mas/delete/plan"
  44. #define URL_POST_QUERY_EVENT_RECORD "/mas/query/eventrecord"
  45. #define URL_POST_QUERY_MEDIA_FILE "/mas/query/mediafile"
  46. #define URL_POST_QUERY_MEDIA_RECORD "/mas/query/mediarecord"
  47. #define URL_POST_QUERY_OP_RECORD "/mas/query/oprecord"
  48. #define URL_POST_QUERY_PERF_RECORD "/mas/query/perfrecord"
  49. #define URL_POST_PIPE_EXCEPTION "/mas/query/scene/exception"
  50. #define URL_POST_CTRL_SCENE "/mas/ctrl/scene"
  51. #define URL_POST_QUERY_SRC_STATE "/mas/query/mediasrcs/state"
  52. #define URL_POST_WABC_FILE_UPLOAD "/mas/upload"
  53. // PUT
  54. #define URL_PUT_REBOOT "/mas/reboot"
  55. #define URL_PUT_LOGIN "/mas/login"
  56. #define URL_PUT_LOGOUT "/mas/logout"
  57. // HTTP Payload Json
  58. template<typename T>
  59. struct CommonRequest {
  60. std::string Token;
  61. T Params;
  62. std::string toJson() const
  63. {
  64. tzc::json::JsonDoc document;
  65. document.SetObject();
  66. tzc::json::setFiled(document, "Token", Token);
  67. tzc::json::setFiledParams(document, "Params", Params);
  68. return tzc::json::ValueToJson(document);
  69. }
  70. static TZ_BOOL fromJson(const std::string & json, CommonRequest & value)
  71. {
  72. tzc::json::JsonDoc document;
  73. document.Parse(json.c_str());
  74. if (document.HasParseError())
  75. {
  76. return FALSE;
  77. }
  78. value.Token = tzc::json::getFiled(document, "Token", "");
  79. tzc::json::getFiledParams(document, "Params", value.Params);
  80. return TRUE;
  81. }
  82. };
  83. template<typename T>
  84. struct CommonResponse {
  85. TZ_INT Code;
  86. std::string Msg;
  87. T Params;
  88. std::string toJson() const
  89. {
  90. tzc::json::JsonDoc document;
  91. document.SetObject();
  92. tzc::json::setFiled(document, "Code", Code);
  93. tzc::json::setFiled(document, "Msg", Msg);
  94. tzc::json::setFiledParams(document, "Params", Params);
  95. return tzc::json::ValueToJson(document);
  96. }
  97. static TZ_BOOL fromJson(const std::string & json, CommonResponse & value)
  98. {
  99. tzc::json::JsonDoc document;
  100. document.Parse(json.c_str());
  101. if (document.HasParseError())
  102. {
  103. return FALSE;
  104. }
  105. value.Code = tzc::json::getFiled(document, "Code", 0);
  106. value.Msg = tzc::json::getFiled(document, "Msg", "");
  107. tzc::json::getFiledParams(document, "Params", value.Params);
  108. return TRUE;
  109. }
  110. };
  111. struct NullStruct {
  112. std::string toJson() const
  113. {
  114. tzc::json::JsonDoc document;
  115. document.SetObject();
  116. return tzc::json::ValueToJson(document);
  117. }
  118. static TZ_BOOL fromJson(const std::string & json, NullStruct & value)
  119. {
  120. tzc::json::JsonDoc document;
  121. document.Parse(json.c_str());
  122. if (document.HasParseError())
  123. {
  124. return FALSE;
  125. }
  126. return TRUE;
  127. }
  128. };
  129. /*用户信息表*/
  130. struct UserInfo {
  131. std::string Username;/*用户名, 主键*/
  132. std::string Password;/*用户密码,MD5加密*/
  133. TZ_INT Role;/*用户类型:管理员/用户*/
  134. TZ_Int64 CreateTime;/*创建时间*/
  135. TZ_Int64 LoginTime;/*登陆时间*/
  136. std::string Description;/*描述信息*/
  137. std::string toJson() const
  138. {
  139. tzc::json::JsonDoc document;
  140. document.SetObject();
  141. tzc::json::setFiled(document, "Username", Username);
  142. tzc::json::setFiled(document, "Password", Password);
  143. tzc::json::setFiled(document, "Role", Role);
  144. tzc::json::setFiled(document, "CreateTime", CreateTime);
  145. tzc::json::setFiled(document, "LoginTime", LoginTime);
  146. tzc::json::setFiled(document, "Description", Description);
  147. return tzc::json::ValueToJson(document);
  148. }
  149. static TZ_BOOL fromJson(const std::string & json, UserInfo & value)
  150. {
  151. tzc::json::JsonDoc document;
  152. document.Parse(json.c_str());
  153. if (document.HasParseError())
  154. {
  155. return FALSE;
  156. }
  157. value.Username = tzc::json::getFiled(document, "Username", "");
  158. value.Password = tzc::json::getFiled(document, "Password", "");
  159. value.Role = tzc::json::getFiled(document, "Role", 0);
  160. value.CreateTime = tzc::json::getFiled(document, "CreateTime", 0LL);
  161. value.LoginTime = tzc::json::getFiled(document, "LoginTime", 0LL);
  162. value.Description = tzc::json::getFiled(document, "Description", "");
  163. return TRUE;
  164. }
  165. };
  166. /*系统配置表*/
  167. struct SysConfig {
  168. std::string ParamKey;/*配置项key,主键*/
  169. std::string ParamValue;/*配置项value*/
  170. std::string ParamGroup;/*配置项组*/
  171. std::string toJson() const
  172. {
  173. tzc::json::JsonDoc document;
  174. document.SetObject();
  175. tzc::json::setFiled(document, "ParamKey", ParamKey);
  176. tzc::json::setFiled(document, "ParamValue", ParamValue);
  177. tzc::json::setFiled(document, "ParamGroup", ParamGroup);
  178. return tzc::json::ValueToJson(document);
  179. }
  180. static TZ_BOOL fromJson(const std::string & json, SysConfig & value)
  181. {
  182. tzc::json::JsonDoc document;
  183. document.Parse(json.c_str());
  184. if (document.HasParseError())
  185. {
  186. return FALSE;
  187. }
  188. value.ParamKey = tzc::json::getFiled(document, "ParamKey", "");
  189. value.ParamValue = tzc::json::getFiled(document, "ParamValue", "");
  190. value.ParamGroup = tzc::json::getFiled(document, "ParamGroup", "");
  191. return TRUE;
  192. }
  193. };
  194. /*媒体资源信息表*/
  195. struct MediaRscInfo {
  196. TZ_INT Id;/*唯一标识主键,自增*/
  197. std::string Name;/*资源名称*/
  198. TZ_INT SrcId;/*媒体源ID*/
  199. TZ_INT Idx;/*序号*/
  200. TZ_INT RscType;/*资源类型:video/audio/mixed*/
  201. TZ_INT TransFormat;/*数据传输格式PS-RTP/RTP*/
  202. TZ_INT EncodeFormat;/*数据编码格式h264/h265*/
  203. TZ_INT StreamType;/*码流类型:主/辅*/
  204. std::string toJson() const
  205. {
  206. tzc::json::JsonDoc document;
  207. document.SetObject();
  208. tzc::json::setFiled(document, "Id", Id);
  209. tzc::json::setFiled(document, "Name", Name);
  210. tzc::json::setFiled(document, "SrcId", SrcId);
  211. tzc::json::setFiled(document, "Idx", Idx);
  212. tzc::json::setFiled(document, "RscType", RscType);
  213. tzc::json::setFiled(document, "TransFormat", TransFormat);
  214. tzc::json::setFiled(document, "EncodeFormat", EncodeFormat);
  215. tzc::json::setFiled(document, "StreamType", StreamType);
  216. return tzc::json::ValueToJson(document);
  217. }
  218. static TZ_BOOL fromJson(const std::string & json, MediaRscInfo & value)
  219. {
  220. tzc::json::JsonDoc document;
  221. document.Parse(json.c_str());
  222. if (document.HasParseError())
  223. {
  224. return FALSE;
  225. }
  226. value.Id = tzc::json::getFiled(document, "Id", 0);
  227. value.Name = tzc::json::getFiled(document, "Name", "");
  228. value.SrcId = tzc::json::getFiled(document, "SrcId", 0);
  229. value.Idx = tzc::json::getFiled(document, "Idx", 0);
  230. value.RscType = tzc::json::getFiled(document, "RscType", 0);
  231. value.TransFormat = tzc::json::getFiled(document, "TransFormat", 0);
  232. value.EncodeFormat = tzc::json::getFiled(document, "EncodeFormat", 0);
  233. value.StreamType = tzc::json::getFiled(document, "StreamType", 0);
  234. return TRUE;
  235. }
  236. };
  237. /*媒体源表*/
  238. struct MediaSrcInfo {
  239. TZ_INT Id;/*唯一标识,主键,自增*/
  240. std::string Name;/*名称*/
  241. TZ_INT Type;/*类型:设备/协议/文件*/
  242. TZ_INT Subtype;/*子类型*/
  243. std::string Address;/*设备地址/通讯地址/文件路径*/
  244. TZ_INT Vendor;/*厂商名称*/
  245. TZ_INT Port;/*设备端口/通讯端口*/
  246. std::string Username;/*设备登录用户名*/
  247. std::string Password;/*设备登录用户密码*/
  248. TZ_INT Mode;/*设备接入方式:SDK/ONVIF*/
  249. TZ_INT Capability;/*设备通道数*/
  250. std::string Detail;/*媒体信息,用于协议类型*/
  251. std::string Description;/*描述信息*/
  252. std::list<MediaRscInfo> MediaRscs;
  253. std::string toJson() const
  254. {
  255. tzc::json::JsonDoc document;
  256. document.SetObject();
  257. tzc::json::setFiled(document, "Id", Id);
  258. tzc::json::setFiled(document, "Name", Name);
  259. tzc::json::setFiled(document, "Type", Type);
  260. tzc::json::setFiled(document, "Subtype", Subtype);
  261. tzc::json::setFiled(document, "Address", Address);
  262. tzc::json::setFiled(document, "Vendor", Vendor);
  263. tzc::json::setFiled(document, "Port", Port);
  264. tzc::json::setFiled(document, "Username", Username);
  265. tzc::json::setFiled(document, "Password", Password);
  266. tzc::json::setFiled(document, "Mode", Mode);
  267. tzc::json::setFiled(document, "Capability", Capability);
  268. tzc::json::setFiled(document, "Detail", Detail);
  269. tzc::json::setFiled(document, "Description", Description);
  270. tzc::json::setFiledArrayObject(document, "MediaRscs", MediaRscs);
  271. return tzc::json::ValueToJson(document);
  272. }
  273. static TZ_BOOL fromJson(const std::string & json, MediaSrcInfo & value)
  274. {
  275. tzc::json::JsonDoc document;
  276. document.Parse(json.c_str());
  277. if (document.HasParseError())
  278. {
  279. return FALSE;
  280. }
  281. value.Id = tzc::json::getFiled(document, "Id", 0);
  282. value.Name = tzc::json::getFiled(document, "Name", "");
  283. value.Type = tzc::json::getFiled(document, "Type", 0);
  284. value.Subtype = tzc::json::getFiled(document, "Subtype", 0);
  285. value.Address = tzc::json::getFiled(document, "Address", "");
  286. value.Vendor = tzc::json::getFiled(document, "Vendor", 0);
  287. value.Port = tzc::json::getFiled(document, "Port", 0);
  288. value.Username = tzc::json::getFiled(document, "Username", "");
  289. value.Password = tzc::json::getFiled(document, "Password", "");
  290. value.Mode = tzc::json::getFiled(document, "Mode", 0);
  291. value.Capability = tzc::json::getFiled(document, "Capability", 0);
  292. value.Detail = tzc::json::getFiled(document, "Detail", "");
  293. value.Description = tzc::json::getFiled(document, "Description", "");
  294. tzc::json::ConverArrayObject(document, "MediaRscs", value.MediaRscs);
  295. return TRUE;
  296. }
  297. };
  298. /*场景与检测单元关联信息表*/
  299. struct SceneDetectorInfo {
  300. TZ_INT Id; /*唯一标识,主键,自增*/
  301. TZ_INT SceneId; /*场景键值,外键*/
  302. TZ_INT DetectorId; /*检测单元键值,外键*/
  303. TZ_INT RscId; /*媒体资源ID,外键*/
  304. TZ_INT Idx; /*索引id*/
  305. TZ_INT SIdx; /*上级索引id*/
  306. std::string DetectorCfg; /*检测单元配置参数Json*/
  307. std::string Description; /*描述信息*/
  308. std::string toJson() const
  309. {
  310. tzc::json::JsonDoc document;
  311. document.SetObject();
  312. tzc::json::setFiled(document, "Id", Id);
  313. tzc::json::setFiled(document, "SceneId", SceneId);
  314. tzc::json::setFiled(document, "DetectorId", DetectorId);
  315. tzc::json::setFiled(document, "RscId", RscId);
  316. tzc::json::setFiled(document, "Idx", Idx);
  317. tzc::json::setFiled(document, "SIdx", SIdx);
  318. tzc::json::setFiled(document, "DetectorCfg", DetectorCfg);
  319. tzc::json::setFiled(document, "Description", Description);
  320. return tzc::json::ValueToJson(document);
  321. }
  322. static TZ_BOOL fromJson(const std::string & json, SceneDetectorInfo & value)
  323. {
  324. tzc::json::JsonDoc document;
  325. document.Parse(json.c_str());
  326. if (document.HasParseError())
  327. {
  328. return FALSE;
  329. }
  330. value.Id = tzc::json::getFiled(document, "Id", 0);
  331. value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
  332. value.DetectorId = tzc::json::getFiled(document, "DetectorId", 0);
  333. value.Idx = tzc::json::getFiled(document, "Idx", 0);
  334. value.SIdx = tzc::json::getFiled(document, "SIdx", 0);
  335. value.RscId = tzc::json::getFiled(document, "RscId", 0);
  336. value.DetectorCfg = tzc::json::getFiled(document, "DetectorCfg", "");
  337. value.Description = tzc::json::getFiled(document, "Description", "");
  338. return TRUE;
  339. }
  340. };
  341. /*场景信息表*/
  342. struct SceneInfo {
  343. TZ_INT Id;/*唯一标识,主键,自增*/
  344. std::string Name;/*场景名称*/
  345. std::string Label;/*场景标签*/
  346. TZ_BOOL Enable;/*是否使能*/
  347. TZ_INT StrategyId;/*判定策略键值,外键*/
  348. std::string StrategyCfg;/*判定策略配置参数Json*/
  349. TZ_BOOL GpuEnable;/*是否开启GPU*/
  350. std::string Description;/*描述信息*/
  351. StrategyInfo Strategy;
  352. std::vector<SceneDetectorInfo> Confs;
  353. std::string toJson() const
  354. {
  355. tzc::json::JsonDoc document;
  356. document.SetObject();
  357. tzc::json::setFiled(document, "Id", Id);
  358. tzc::json::setFiled(document, "Name", Name);
  359. tzc::json::setFiled(document, "Label", Label);
  360. tzc::json::setFiled(document, "Enable", Enable);
  361. tzc::json::setFiled(document, "StrategyId", StrategyId);
  362. tzc::json::setFiled(document, "StrategyCfg", StrategyCfg);
  363. tzc::json::setFiled(document, "GpuEnable", GpuEnable);
  364. tzc::json::setFiled(document, "Description", Description);
  365. tzc::json::setFiledParams(document, "Strategy", Strategy);
  366. tzc::json::setFiledParams(document, "Confs", Confs);
  367. return tzc::json::ValueToJson(document);
  368. }
  369. static TZ_BOOL fromJson(const std::string & json, SceneInfo & value)
  370. {
  371. tzc::json::JsonDoc document;
  372. document.Parse(json.c_str());
  373. if (document.HasParseError())
  374. {
  375. return FALSE;
  376. }
  377. value.Id = tzc::json::getFiled(document, "Id", 0);
  378. value.Name = tzc::json::getFiled(document, "Name", "");
  379. value.Label = tzc::json::getFiled(document, "Label", "");
  380. value.Enable = tzc::json::getFiled(document, "Enable", false);
  381. value.StrategyId = tzc::json::getFiled(document, "StrategyId", 0);
  382. value.StrategyCfg = tzc::json::getFiled(document, "StrategyCfg", "");
  383. value.GpuEnable = tzc::json::getFiled(document, "GpuEnable", false);
  384. value.Description = tzc::json::getFiled(document, "Description", "");
  385. TZ_BOOL rst;
  386. rst &= tzc::json::getFiledParams(document, "Strategy", value.Strategy);
  387. rst &= tzc::json::getFiledParams(document, "Confs", value.Confs);
  388. return TRUE;
  389. }
  390. };
  391. /*场景组信息表*/
  392. struct SceneGroup {
  393. TZ_INT Id;/*唯一标识,主键,自增*/
  394. std::string Name;/*场景组名称*/
  395. std::string Label;/*场景组标签*/
  396. std::vector<SceneInfo> Scenes;
  397. std::string toJson() const
  398. {
  399. tzc::json::JsonDoc document;
  400. document.SetObject();
  401. tzc::json::setFiled(document, "Id", Id);
  402. tzc::json::setFiled(document, "Name", Name);
  403. tzc::json::setFiled(document, "Label", Label);
  404. tzc::json::setFiledParams(document, "Scenes", Scenes);
  405. return tzc::json::ValueToJson(document);
  406. }
  407. static TZ_BOOL fromJson(const std::string & json, SceneGroup & value)
  408. {
  409. tzc::json::JsonDoc document;
  410. document.Parse(json.c_str());
  411. if (document.HasParseError())
  412. {
  413. return FALSE;
  414. }
  415. value.Id = tzc::json::getFiled(document, "Id", 0);
  416. value.Name = tzc::json::getFiled(document, "Name", "");
  417. value.Label = tzc::json::getFiled(document, "Label", "");
  418. tzc::json::getFiledParams(document, "Scenes", value.Scenes);
  419. return TRUE;
  420. }
  421. };
  422. /*计划任务信息表*/
  423. struct PlanInfo {
  424. TZ_INT Id;/*唯一标识,主键,自增*/
  425. TZ_BOOL Reverse;/*反向配置标识*/
  426. TZ_INT Type;/*计划类型:日计划/周计划/月计划/特殊计划*/
  427. TZ_Int64 Time;/*时间段使能标识*/
  428. TZ_INT Day;/*用于周/月计划*/
  429. std::string Date;/*有效日期*/
  430. std::string Description;/*描述信息*/
  431. SceneInfo Scene;
  432. std::string toJson() const
  433. {
  434. tzc::json::JsonDoc document;
  435. document.SetObject();
  436. tzc::json::setFiled(document, "Id", Id);
  437. tzc::json::setFiled(document, "Reverse", Reverse);
  438. tzc::json::setFiled(document, "Type", Type);
  439. tzc::json::setFiled(document, "Time", Time);
  440. tzc::json::setFiled(document, "Day", Day);
  441. tzc::json::setFiled(document, "Date", Date);
  442. tzc::json::setFiled(document, "Description", Description);
  443. tzc::json::setFiledParams(document, "Scene", Scene);
  444. return tzc::json::ValueToJson(document);
  445. }
  446. static TZ_BOOL fromJson(const std::string & json, PlanInfo & value)
  447. {
  448. tzc::json::JsonDoc document;
  449. document.Parse(json.c_str());
  450. if (document.HasParseError())
  451. {
  452. return FALSE;
  453. }
  454. value.Id = tzc::json::getFiled(document, "Id", 0);
  455. value.Reverse = tzc::json::getFiled(document, "Reverse", false);
  456. value.Type = tzc::json::getFiled(document, "Type", 0);
  457. value.Time = tzc::json::getFiled(document, "Time", 0LL);
  458. value.Day = tzc::json::getFiled(document, "Day", 0);
  459. value.Date = tzc::json::getFiled(document, "Date", "");
  460. value.Description = tzc::json::getFiled(document, "Description", "");
  461. TZ_BOOL rst;
  462. rst&= tzc::json::getFiledParams(document, "Scene", value.Scene);
  463. return TRUE;
  464. }
  465. };
  466. /*事件记录表*/
  467. struct EventRecord {
  468. TZ_INT Id;/*唯一标识,主键,自增*/
  469. std::string Type;/*事件类型*/
  470. std::string Name;/*事件名称*/
  471. std::string Externs;/*额外描述信息*/
  472. TZ_INT SceneId;/*场景ID*/
  473. std::string SceneName;/*场景名称*/
  474. std::string StrategyName;/*判定策略名称*/
  475. TZ_Int64 BeginTime;/*开始时间戳*/
  476. TZ_Int64 EndTime;/*结束时间戳*/
  477. std::string Description;/*描述信息*/
  478. std::string toJson() const
  479. {
  480. tzc::json::JsonDoc document;
  481. document.SetObject();
  482. tzc::json::setFiled(document, "Id", Id);
  483. tzc::json::setFiled(document, "Type", Type);
  484. tzc::json::setFiled(document, "Name", Name);
  485. tzc::json::setFiled(document, "Externs", Externs);
  486. tzc::json::setFiled(document, "SceneId", SceneId);
  487. tzc::json::setFiled(document, "SceneName", SceneName);
  488. tzc::json::setFiled(document, "StrategyName", StrategyName);
  489. tzc::json::setFiled(document, "BeginTime", BeginTime);
  490. tzc::json::setFiled(document, "EndTime", EndTime);
  491. tzc::json::setFiled(document, "Description", Description);
  492. return tzc::json::ValueToJson(document);
  493. }
  494. static TZ_BOOL fromJson(const std::string & json, EventRecord & value)
  495. {
  496. tzc::json::JsonDoc document;
  497. document.Parse(json.c_str());
  498. if (document.HasParseError())
  499. {
  500. return FALSE;
  501. }
  502. value.Id = tzc::json::getFiled(document, "Id", 0);
  503. value.Type = tzc::json::getFiled(document, "Type", "");
  504. value.Name = tzc::json::getFiled(document, "Name", "");
  505. value.Externs = tzc::json::getFiled(document, "Externs", "");
  506. value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
  507. value.SceneName = tzc::json::getFiled(document, "SceneName", "");
  508. value.StrategyName = tzc::json::getFiled(document, "StrategyName", "");
  509. value.BeginTime = tzc::json::getFiled(document, "BeginTime", 0LL);
  510. value.EndTime = tzc::json::getFiled(document, "EndTime", 0LL);
  511. value.Description = tzc::json::getFiled(document, "Description", "");
  512. return TRUE;
  513. }
  514. };
  515. /*媒体记录表*/
  516. struct MediaRecord {
  517. TZ_INT Id;/*唯一标识,主键,自增*/
  518. TZ_INT RscId;/*媒体资源ID*/
  519. std::string Name;/*记录名称*/
  520. TZ_INT Type;/*记录类型:视频*/
  521. TZ_Int64 CreateTime;/*创建时间戳*/
  522. TZ_INT Duration;/*视频文件时长(秒)*/
  523. TZ_INT Size;/*文件大小(字节)*/
  524. std::string Path;/*本地文件路径*/
  525. std::string Description;/*描述信息*/
  526. std::string toJson() const
  527. {
  528. tzc::json::JsonDoc document;
  529. document.SetObject();
  530. tzc::json::setFiled(document, "Id", Id);
  531. tzc::json::setFiled(document, "RscId", RscId);
  532. tzc::json::setFiled(document, "Name", Name);
  533. tzc::json::setFiled(document, "Type", Type);
  534. tzc::json::setFiled(document, "CreateTime", CreateTime);
  535. tzc::json::setFiled(document, "Duration", Duration);
  536. tzc::json::setFiled(document, "Size", Size);
  537. tzc::json::setFiled(document, "Path", Path);
  538. tzc::json::setFiled(document, "Description", Description);
  539. return tzc::json::ValueToJson(document);
  540. }
  541. static TZ_BOOL fromJson(const std::string & json, MediaRecord & value)
  542. {
  543. tzc::json::JsonDoc document;
  544. document.Parse(json.c_str());
  545. if (document.HasParseError())
  546. {
  547. return FALSE;
  548. }
  549. value.Id = tzc::json::getFiled(document, "Id", 0);
  550. value.RscId = tzc::json::getFiled(document, "RscId", 0);
  551. value.Name = tzc::json::getFiled(document, "Name", "");
  552. value.Type = tzc::json::getFiled(document, "Type", 0);
  553. value.CreateTime = tzc::json::getFiled(document, "CreateTime", 0LL);
  554. value.Duration = tzc::json::getFiled(document, "Duration", 0);
  555. value.Size = tzc::json::getFiled(document, "Size", 0);
  556. value.Path = tzc::json::getFiled(document, "Path", "");
  557. value.Description = tzc::json::getFiled(document, "Description", "");
  558. return TRUE;
  559. }
  560. };
  561. /*操作记录表*/
  562. struct OpRecord {
  563. TZ_INT Id;/*唯一标识,主键,自增*/
  564. std::string Operation;/*操作*/
  565. TZ_INT Result;/*操作结果*/
  566. std::string Username;/*操作用户*/
  567. std::string UserAddr;/*操作用户登录地址*/
  568. TZ_Int64 OccurTime;/*时间戳*/
  569. std::string Description;/*描述信息*/
  570. std::string toJson() const
  571. {
  572. tzc::json::JsonDoc document;
  573. document.SetObject();
  574. tzc::json::setFiled(document, "Id", Id);
  575. tzc::json::setFiled(document, "Operation", Operation);
  576. tzc::json::setFiled(document, "Result", Result);
  577. tzc::json::setFiled(document, "Username", Username);
  578. tzc::json::setFiled(document, "UserAddr", UserAddr);
  579. tzc::json::setFiled(document, "OccurTime", OccurTime);
  580. tzc::json::setFiled(document, "Description", Description);
  581. return tzc::json::ValueToJson(document);
  582. }
  583. static TZ_BOOL fromJson(const std::string & json, OpRecord & value)
  584. {
  585. tzc::json::JsonDoc document;
  586. document.Parse(json.c_str());
  587. if (document.HasParseError())
  588. {
  589. return FALSE;
  590. }
  591. value.Id = tzc::json::getFiled(document, "Id", 0);
  592. value.Operation = tzc::json::getFiled(document, "Operation", "");
  593. value.Result = tzc::json::getFiled(document, "Result", 0);
  594. value.Username = tzc::json::getFiled(document, "Username", "");
  595. value.UserAddr = tzc::json::getFiled(document, "UserAddr", "");
  596. value.OccurTime = tzc::json::getFiled(document, "OccurTime", 0LL);
  597. value.Description = tzc::json::getFiled(document, "Description", "");
  598. return TRUE;
  599. }
  600. };
  601. /*性能记录表*/
  602. struct PerformanceRecord {
  603. TZ_INT Id;/*唯一标识,主键,自增*/
  604. TZ_Int64 RecordTime;/*时间戳*/
  605. TZ_INT Cpu;/*CPU平均使用率(%)*/
  606. TZ_INT Memory;/*内存占用率(%)*/
  607. TZ_INT Nic;/*网卡平均使用率(%)*/
  608. TZ_INT GpuUtil;/*GPU平均使用率(%)*/
  609. TZ_INT GpuMemory;/*GPU显存占用率(%)*/
  610. TZ_INT Disk;/*硬盘使用率(%)*/
  611. std::string toJson() const
  612. {
  613. tzc::json::JsonDoc document;
  614. document.SetObject();
  615. tzc::json::setFiled(document, "Id", Id);
  616. tzc::json::setFiled(document, "RecordTime", RecordTime);
  617. tzc::json::setFiled(document, "Cpu", Cpu);
  618. tzc::json::setFiled(document, "Memory", Memory);
  619. tzc::json::setFiled(document, "Nic", Nic);
  620. tzc::json::setFiled(document, "GpuUtil", GpuUtil);
  621. tzc::json::setFiled(document, "GpuMemory", GpuMemory);
  622. tzc::json::setFiled(document, "Disk", Disk);
  623. return tzc::json::ValueToJson(document);
  624. }
  625. static TZ_BOOL fromJson(const std::string & json, PerformanceRecord & value)
  626. {
  627. tzc::json::JsonDoc document;
  628. document.Parse(json.c_str());
  629. if (document.HasParseError())
  630. {
  631. return FALSE;
  632. }
  633. value.Id = tzc::json::getFiled(document, "Id", 0);
  634. value.RecordTime = tzc::json::getFiled(document, "RecordTime", 0LL);
  635. value.Cpu = tzc::json::getFiled(document, "Cpu", 0);
  636. value.Memory = tzc::json::getFiled(document, "Memory", 0);
  637. value.Nic = tzc::json::getFiled(document, "Nic", 0);
  638. value.GpuUtil = tzc::json::getFiled(document, "GpuUtil", 0);
  639. value.GpuMemory = tzc::json::getFiled(document, "GpuMemory", 0);
  640. value.Disk = tzc::json::getFiled(document, "Disk", 0);
  641. return TRUE;
  642. }
  643. };
  644. /* 数据库信息 */
  645. struct DBInfo {
  646. std::string DbVersion;/*数据库版本号,主键*/
  647. std::string EditTime;/*数据库创建或更新的时间*/
  648. std::string Reserved;/*预留字段*/
  649. std::string toJson() const
  650. {
  651. tzc::json::JsonDoc document;
  652. document.SetObject();
  653. tzc::json::setFiled(document, "DbVersion", DbVersion);
  654. tzc::json::setFiled(document, "EditTime", EditTime);
  655. tzc::json::setFiled(document, "Reserved", Reserved);
  656. return tzc::json::ValueToJson(document);
  657. }
  658. static TZ_BOOL fromJson(const std::string & json, DBInfo & value)
  659. {
  660. tzc::json::JsonDoc document;
  661. document.Parse(json.c_str());
  662. if (document.HasParseError())
  663. {
  664. return FALSE;
  665. }
  666. value.DbVersion = tzc::json::getFiled(document, "DbVersion", "");
  667. value.EditTime = tzc::json::getFiled(document, "EditTime", "");
  668. value.Reserved = tzc::json::getFiled(document, "Reserved", "");
  669. return TRUE;
  670. }
  671. };
  672. /*场景组和场景关联关系表*/
  673. struct SgroupScene {
  674. TZ_INT SceneGrpId;/*场景组id和scene_id联合主键*/
  675. TZ_INT SceneId;/*场景id和scene_grp_id联合主键*/
  676. std::string toJson() const
  677. {
  678. tzc::json::JsonDoc document;
  679. document.SetObject();
  680. tzc::json::setFiled(document, "SceneGrpId", SceneGrpId);
  681. tzc::json::setFiled(document, "SceneId", SceneId);
  682. return tzc::json::ValueToJson(document);
  683. }
  684. static TZ_BOOL fromJson(const std::string & json, SgroupScene & value)
  685. {
  686. tzc::json::JsonDoc document;
  687. document.Parse(json.c_str());
  688. if (document.HasParseError())
  689. {
  690. return FALSE;
  691. }
  692. value.SceneGrpId = tzc::json::getFiled(document, "SceneGrpId", 0);
  693. value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
  694. return TRUE;
  695. }
  696. };
  697. /*数据库版本信息*/
  698. struct DbVersionInfo {
  699. std::string DbVersion;/*数据库版本号*/
  700. std::string toJson() const
  701. {
  702. tzc::json::JsonDoc document;
  703. document.SetObject();
  704. tzc::json::setFiled(document, "DbVersion", DbVersion);
  705. return tzc::json::ValueToJson(document);
  706. }
  707. static TZ_BOOL fromJson(const std::string & json, DbVersionInfo & value)
  708. {
  709. tzc::json::JsonDoc document;
  710. document.Parse(json.c_str());
  711. if (document.HasParseError())
  712. {
  713. return FALSE;
  714. }
  715. value.DbVersion = tzc::json::getFiled(document, "DbVersion", "");
  716. return TRUE;
  717. }
  718. };
  719. /*通用字符串*/
  720. struct StringInfo {
  721. std::string Info;/*内容*/
  722. std::string toJson() const
  723. {
  724. tzc::json::JsonDoc document;
  725. document.SetObject();
  726. tzc::json::setFiled(document, "Info", Info);
  727. return tzc::json::ValueToJson(document);
  728. }
  729. static TZ_BOOL fromJson(const std::string & json, StringInfo & value)
  730. {
  731. tzc::json::JsonDoc document;
  732. document.Parse(json.c_str());
  733. if (document.HasParseError())
  734. {
  735. return FALSE;
  736. }
  737. value.Info = tzc::json::getFiled(document, "Info", "");
  738. return TRUE;
  739. }
  740. };
  741. /*通用数值*/
  742. struct NumberInfo {
  743. TZ_INT Info;/*通用number信息*/
  744. std::string toJson() const
  745. {
  746. tzc::json::JsonDoc document;
  747. document.SetObject();
  748. tzc::json::setFiled(document, "Info", Info);
  749. return tzc::json::ValueToJson(document);
  750. }
  751. static TZ_BOOL fromJson(const std::string & json, NumberInfo & value)
  752. {
  753. tzc::json::JsonDoc document;
  754. document.Parse(json.c_str());
  755. if (document.HasParseError())
  756. {
  757. return FALSE;
  758. }
  759. value.Info = tzc::json::getFiled(document, "Info", 0);
  760. return TRUE;
  761. }
  762. };
  763. /*媒体源状态*/
  764. struct MediaRscState {
  765. TZ_INT Id;/*媒体源id*/
  766. TZ_BOOL State;/*状态*/
  767. std::string toJson() const
  768. {
  769. tzc::json::JsonDoc document;
  770. document.SetObject();
  771. tzc::json::setFiled(document, "Id", Id);
  772. tzc::json::setFiled(document, "State", State);
  773. return tzc::json::ValueToJson(document);
  774. }
  775. static TZ_BOOL fromJson(const std::string & json, MediaRscState & value)
  776. {
  777. tzc::json::JsonDoc document;
  778. document.Parse(json.c_str());
  779. if (document.HasParseError())
  780. {
  781. return FALSE;
  782. }
  783. value.Id = tzc::json::getFiled(document, "Id", 0);
  784. value.State = tzc::json::getFiled(document, "State", false);
  785. return TRUE;
  786. }
  787. };
  788. /*翻页查询结果*/
  789. struct PageResult {
  790. TZ_INT Total;/*总数*/
  791. TZ_INT TotalPage;/*总页数*/
  792. TZ_INT Page;/*页码*/
  793. TZ_INT Num;/*每页数量*/
  794. std::string toJson() const
  795. {
  796. tzc::json::JsonDoc document;
  797. document.SetObject();
  798. tzc::json::setFiled(document, "Total", Total);
  799. tzc::json::setFiled(document, "TotalPage", TotalPage);
  800. tzc::json::setFiled(document, "Page", Page);
  801. tzc::json::setFiled(document, "Num", Num);
  802. return tzc::json::ValueToJson(document);
  803. }
  804. static TZ_BOOL fromJson(const std::string & json, PageResult & value)
  805. {
  806. tzc::json::JsonDoc document;
  807. document.Parse(json.c_str());
  808. if (document.HasParseError())
  809. {
  810. return FALSE;
  811. }
  812. value.Total = tzc::json::getFiled(document, "Total", 0);
  813. value.TotalPage = tzc::json::getFiled(document, "TotalPage", 0);
  814. value.Page = tzc::json::getFiled(document, "Page", 0);
  815. value.Num = tzc::json::getFiled(document, "Num", 0);
  816. return TRUE;
  817. }
  818. };
  819. /*数据通道故障信息*/
  820. struct PipeException {
  821. TZ_INT SceneID;/*场景ID*/
  822. TZ_HANDLE Tag;/*通道Tag*/
  823. TZ_HANDLE SuperTag;/*上级通道Tag*/
  824. TZ_INT Threshold;/*阈值*/
  825. TZ_INT Type; /*通道类型:检测单元接收数据通道
  826. 判定策略接收数据通道
  827. WSS接收检测结果/数据通道
  828. RTSP接收数据流通道*/
  829. TZ_INT Status;/*状态:
  830. 无数据
  831. 数据超时
  832. 正常
  833. */
  834. std::string SceneName;/*场景名称*/
  835. std::string Name;/*通道名称*/
  836. std::string toJson() const
  837. {
  838. tzc::json::JsonDoc document;
  839. document.SetObject();
  840. tzc::json::setFiled(document, "SceneID", SceneID);
  841. tzc::json::setFiled(document, "Tag", Tag);
  842. tzc::json::setFiled(document, "SuperTag", SuperTag);
  843. tzc::json::setFiled(document, "Threshold", Threshold);
  844. tzc::json::setFiled(document, "Type", Type);
  845. tzc::json::setFiled(document, "Status", Status);
  846. tzc::json::setFiled(document, "SceneName", SceneName);
  847. tzc::json::setFiled(document, "Name", Name);
  848. return tzc::json::ValueToJson(document);
  849. }
  850. static TZ_BOOL fromJson(const std::string & json, PipeException & value)
  851. {
  852. tzc::json::JsonDoc document;
  853. document.Parse(json.c_str());
  854. if (document.HasParseError())
  855. {
  856. return FALSE;
  857. }
  858. value.SceneID = tzc::json::getFiled(document, "SceneID", 0);
  859. value.Tag = tzc::json::getFiled(document, "Tag", 0);
  860. value.SuperTag = tzc::json::getFiled(document, "SuperTag", 0);
  861. value.Threshold = tzc::json::getFiled(document, "Threshold", 0);
  862. value.Type = tzc::json::getFiled(document, "Type", 0);
  863. value.Status = tzc::json::getFiled(document, "Status", 0);
  864. value.SceneName = tzc::json::getFiled(document, "SceneName", "");
  865. value.Name = tzc::json::getFiled(document, "Name", "");
  866. return TRUE;
  867. }
  868. };
  869. /*内存使用情况*/
  870. struct MemoryUsage {
  871. TZ_FLOAT Size;/*内存占用量(MB)*/
  872. TZ_FLOAT Proportion;/*内存占用率(%)*/
  873. std::string toJson() const
  874. {
  875. tzc::json::JsonDoc document;
  876. document.SetObject();
  877. tzc::json::setFiled(document, "Size", Size);
  878. tzc::json::setFiled(document, "Proportion", Proportion);
  879. return tzc::json::ValueToJson(document);
  880. }
  881. static TZ_BOOL fromJson(const std::string & json, MemoryUsage & value)
  882. {
  883. tzc::json::JsonDoc document;
  884. document.Parse(json.c_str());
  885. if (document.HasParseError())
  886. {
  887. return FALSE;
  888. }
  889. value.Size = tzc::json::getFiled(document, "Size", 0.0f);
  890. value.Proportion = tzc::json::getFiled(document, "Proportion", 0.0f);
  891. return TRUE;
  892. }
  893. };
  894. struct SceneGroupInfo {
  895. TZ_INT Id;
  896. std::string Name;
  897. std::string Label;
  898. std::list<SceneInfo> Scenes;
  899. std::string toJson() const
  900. {
  901. tzc::json::JsonDoc document;
  902. document.SetObject();
  903. tzc::json::setFiled(document, "Id", Id);
  904. tzc::json::setFiled(document, "Name", Name);
  905. tzc::json::setFiled(document, "Label", Label);
  906. tzc::json::setFiledParams(document, "Scenes", Scenes);
  907. return tzc::json::ValueToJson(document);
  908. }
  909. static TZ_BOOL fromJson(const std::string & json, SceneGroupInfo & value)
  910. {
  911. tzc::json::JsonDoc document;
  912. document.Parse(json.c_str());
  913. if (document.HasParseError())
  914. {
  915. return FALSE;
  916. }
  917. value.Id = tzc::json::getFiled(document, "Id", 0);
  918. value.Name = tzc::json::getFiled(document, "Name", "");
  919. value.Label = tzc::json::getFiled(document, "Label", "");
  920. tzc::json::getFiledParams(document, "Scenes", value.Scenes);
  921. return TRUE;
  922. }
  923. };
  924. struct MediaFileCond {
  925. TZ_INT RscId;
  926. TZ_INT BeginTime;
  927. TZ_INT EndTime;
  928. std::string toJson() const
  929. {
  930. tzc::json::JsonDoc document;
  931. document.SetObject();
  932. tzc::json::setFiled(document, "RscId", RscId);
  933. tzc::json::setFiled(document, "BeginTime", BeginTime);
  934. tzc::json::setFiled(document, "EndTime", EndTime);
  935. return tzc::json::ValueToJson(document);
  936. }
  937. static TZ_BOOL fromJson(const std::string & json, MediaFileCond & value)
  938. {
  939. tzc::json::JsonDoc document;
  940. document.Parse(json.c_str());
  941. if (document.HasParseError())
  942. {
  943. return FALSE;
  944. }
  945. value.RscId = tzc::json::getFiled(document, "RscId", 0);
  946. value.BeginTime = tzc::json::getFiled(document, "BeginTime", 0);
  947. value.EndTime = tzc::json::getFiled(document, "EndTime", 0);
  948. return TRUE;
  949. }
  950. };
  951. struct MediaFileInfo {
  952. TZ_INT Type;// EN_MAS_MEDIA_FILE_TYPE
  953. std::string Url;
  954. std::string toJson() const
  955. {
  956. tzc::json::JsonDoc document;
  957. document.SetObject();
  958. tzc::json::setFiled(document, "Type", Type);
  959. tzc::json::setFiled(document, "Url", Url);
  960. return tzc::json::ValueToJson(document);
  961. }
  962. static TZ_BOOL fromJson(const std::string & json, MediaFileInfo & value)
  963. {
  964. tzc::json::JsonDoc document;
  965. document.Parse(json.c_str());
  966. if (document.HasParseError())
  967. {
  968. return FALSE;
  969. }
  970. value.Type = tzc::json::getFiled(document, "Type", 0);
  971. value.Url = tzc::json::getFiled(document, "Url", "");
  972. return TRUE;
  973. }
  974. };
  975. struct CtrlSceneInfo {
  976. TZ_INT Open;
  977. TZ_INT SceneId;
  978. std::string toJson() const
  979. {
  980. tzc::json::JsonDoc document;
  981. document.SetObject();
  982. tzc::json::setFiled(document, "Open", Open);
  983. tzc::json::setFiled(document, "SceneId", SceneId);
  984. return tzc::json::ValueToJson(document);
  985. }
  986. static TZ_BOOL fromJson(const std::string & json, CtrlSceneInfo & value)
  987. {
  988. tzc::json::JsonDoc document;
  989. document.Parse(json.c_str());
  990. if (document.HasParseError())
  991. {
  992. return FALSE;
  993. }
  994. value.Open = tzc::json::getFiled(document, "Open", 0);
  995. value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
  996. return TRUE;
  997. }
  998. };
  999. struct LoginInfo {
  1000. std::string UName;
  1001. std::string UPwd;
  1002. std::string toJson() const
  1003. {
  1004. tzc::json::JsonDoc document;
  1005. document.SetObject();
  1006. tzc::json::setFiled(document, "UName", UName);
  1007. tzc::json::setFiled(document, "UPwd", UPwd);
  1008. return tzc::json::ValueToJson(document);
  1009. }
  1010. static TZ_BOOL fromJson(const std::string & json, LoginInfo & value)
  1011. {
  1012. tzc::json::JsonDoc document;
  1013. document.Parse(json.c_str());
  1014. if (document.HasParseError())
  1015. {
  1016. return FALSE;
  1017. }
  1018. value.UName = tzc::json::getFiled(document, "UName", "");
  1019. value.UPwd = tzc::json::getFiled(document, "UPwd", "");
  1020. return TRUE;
  1021. }
  1022. };
  1023. template<class T>
  1024. struct PageInfos {
  1025. PageResult PageInfo;
  1026. std::list<T> Infos;
  1027. std::string toJson() const
  1028. {
  1029. tzc::json::JsonDoc document;
  1030. document.SetObject();
  1031. tzc::json::setFiledParams(document, "PageInfo", PageInfo);
  1032. tzc::json::setFiledParams(document, "Infos", Infos);
  1033. return tzc::json::ValueToJson(document);
  1034. }
  1035. static TZ_BOOL fromJson(const std::string & json, PageInfos & value)
  1036. {
  1037. tzc::json::JsonDoc document;
  1038. document.Parse(json.c_str());
  1039. if (document.HasParseError())
  1040. {
  1041. return FALSE;
  1042. }
  1043. TZ_BOOL rst = TRUE;
  1044. rst &= tzc::json::getFiledParams(document, "PageInfo", value.PageInfo);
  1045. rst &= tzc::json::getFiledParams(document, "Infos", value.Infos);
  1046. return TRUE;
  1047. }
  1048. };
  1049. struct DevStateInfo {
  1050. TZ_INT SrcId;
  1051. TZ_INT State;
  1052. std::string toJson() const
  1053. {
  1054. tzc::json::JsonDoc document;
  1055. document.SetObject();
  1056. tzc::json::setFiled(document, "SrcId", SrcId);
  1057. tzc::json::setFiled(document, "State", State);
  1058. return tzc::json::ValueToJson(document);
  1059. }
  1060. static TZ_BOOL fromJson(const std::string & json, DevStateInfo & value)
  1061. {
  1062. tzc::json::JsonDoc document;
  1063. document.Parse(json.c_str());
  1064. if (document.HasParseError())
  1065. {
  1066. return FALSE;
  1067. }
  1068. value.SrcId = tzc::json::getFiled(document, "SrcId", 0);
  1069. value.State = tzc::json::getFiled(document, "State", 0);
  1070. return TRUE;
  1071. }
  1072. };
  1073. struct WssStreamInfo {
  1074. TZ_INT Seq;
  1075. std::string Data;
  1076. std::string toJson() const
  1077. {
  1078. tzc::json::JsonDoc document;
  1079. document.SetObject();
  1080. tzc::json::setFiled(document, "Seq", Seq);
  1081. tzc::json::setFiled(document, "Data", Data);
  1082. return tzc::json::ValueToJson(document);
  1083. }
  1084. static TZ_BOOL fromJson(const std::string & json, WssStreamInfo & value)
  1085. {
  1086. tzc::json::JsonDoc document;
  1087. document.Parse(json.c_str());
  1088. if (document.HasParseError())
  1089. {
  1090. return FALSE;
  1091. }
  1092. value.Seq = tzc::json::getFiled(document, "Seq", 0);
  1093. value.Data = tzc::json::getFiled(document, "Data", "");
  1094. return TRUE;
  1095. }
  1096. };
  1097. struct PredicateInfo {
  1098. TZ_INT Code;// EN_COMPARE
  1099. std::string Key;
  1100. std::string Value;
  1101. std::string toJson() const
  1102. {
  1103. tzc::json::JsonDoc document;
  1104. document.SetObject();
  1105. tzc::json::setFiled(document, "Code", Code);
  1106. tzc::json::setFiled(document, "Key", Key);
  1107. tzc::json::setFiled(document, "Value", Value);
  1108. return tzc::json::ValueToJson(document);
  1109. }
  1110. static TZ_BOOL fromJson(const std::string & json, PredicateInfo & value)
  1111. {
  1112. tzc::json::JsonDoc document;
  1113. document.Parse(json.c_str());
  1114. if (document.HasParseError())
  1115. {
  1116. return FALSE;
  1117. }
  1118. value.Code = tzc::json::getFiled(document, "Code", 0);
  1119. value.Key = tzc::json::getFiled(document, "Key", "");
  1120. value.Value = tzc::json::getFiled(document, "Value", "");
  1121. return TRUE;
  1122. }
  1123. };
  1124. struct SortInfo {
  1125. std::string Key;
  1126. TZ_INT Value;// EN_ORDER
  1127. std::string toJson() const
  1128. {
  1129. tzc::json::JsonDoc document;
  1130. document.SetObject();
  1131. tzc::json::setFiled(document, "Key", Key);
  1132. tzc::json::setFiled(document, "Value", Value);
  1133. return tzc::json::ValueToJson(document);
  1134. }
  1135. static TZ_BOOL fromJson(const std::string & json, SortInfo & value)
  1136. {
  1137. tzc::json::JsonDoc document;
  1138. document.Parse(json.c_str());
  1139. if (document.HasParseError())
  1140. {
  1141. return FALSE;
  1142. }
  1143. value.Key = tzc::json::getFiled(document, "Key", "");
  1144. value.Value = tzc::json::getFiled(document, "Value", 0);
  1145. return TRUE;
  1146. }
  1147. };
  1148. struct QueryCondition {
  1149. TZ_INT Page;
  1150. TZ_INT Size;
  1151. std::list<PredicateInfo> Predicates;
  1152. std::list<SortInfo> Sorts;
  1153. std::string toJson() const
  1154. {
  1155. tzc::json::JsonDoc document;
  1156. document.SetObject();
  1157. tzc::json::setFiled(document, "Page", Page);
  1158. tzc::json::setFiled(document, "Size", Size);
  1159. tzc::json::setFiledParams(document, "Predicates", Predicates);
  1160. tzc::json::setFiledParams(document, "Sorts", Sorts);
  1161. return tzc::json::ValueToJson(document);
  1162. }
  1163. static TZ_BOOL fromJson(const std::string & json, QueryCondition & value)
  1164. {
  1165. tzc::json::JsonDoc document;
  1166. document.Parse(json.c_str());
  1167. if (document.HasParseError())
  1168. {
  1169. return FALSE;
  1170. }
  1171. value.Page = tzc::json::getFiled(document, "Page", 0);
  1172. value.Size = tzc::json::getFiled(document, "Size", 0);
  1173. TZ_BOOL rst = TRUE;
  1174. rst &= tzc::json::getFiledParams(document, "Predicates", value.Predicates);
  1175. rst &= tzc::json::getFiledParams(document, "Sorts", value.Sorts);
  1176. return TRUE;
  1177. }
  1178. };
  1179. struct PlayInfo {
  1180. TZ_INT RscId;
  1181. TZ_Int64 PlayHd;
  1182. std::string toJson() const
  1183. {
  1184. tzc::json::JsonDoc document;
  1185. document.SetObject();
  1186. tzc::json::setFiled(document, "RscId", RscId);
  1187. tzc::json::setFiled(document, "PlayHd", PlayHd);
  1188. return tzc::json::ValueToJson(document);
  1189. }
  1190. static TZ_BOOL fromJson(const std::string & json, PlayInfo & value)
  1191. {
  1192. tzc::json::JsonDoc document;
  1193. document.Parse(json.c_str());
  1194. if (document.HasParseError())
  1195. {
  1196. return FALSE;
  1197. }
  1198. value.RscId = tzc::json::getFiled(document, "RscId", 0);
  1199. value.PlayHd = tzc::json::getFiled(document, "PlayHd", 0LL);
  1200. return TRUE;
  1201. }
  1202. };
  1203. struct SubDrawInfo {
  1204. TZ_INT SceneId;
  1205. TZ_BOOL OpFlag;
  1206. std::vector<PlayInfo> PlayHds;
  1207. std::string toJson() const
  1208. {
  1209. tzc::json::JsonDoc document;
  1210. document.SetObject();
  1211. tzc::json::setFiled(document, "SceneId", SceneId);
  1212. tzc::json::setFiled(document, "OpFlag", OpFlag);
  1213. tzc::json::setFiledParams(document, "PlayHds", PlayHds);
  1214. return tzc::json::ValueToJson(document);
  1215. }
  1216. static TZ_BOOL fromJson(const std::string & json, SubDrawInfo & value)
  1217. {
  1218. tzc::json::JsonDoc document;
  1219. document.Parse(json.c_str());
  1220. if (document.HasParseError())
  1221. {
  1222. return false;
  1223. }
  1224. value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
  1225. value.OpFlag = tzc::json::getFiled(document, "OpFlag", FALSE);
  1226. tzc::json::getFiledParams(document, "PlayHds", value.PlayHds);
  1227. return TRUE;
  1228. }
  1229. };
  1230. struct WSSubInfo {
  1231. std::string UName; // 用户名
  1232. std::string Token;
  1233. std::string toJson() const
  1234. {
  1235. tzc::json::JsonDoc document;
  1236. document.SetObject();
  1237. tzc::json::setFiled(document, "UName", UName);
  1238. tzc::json::setFiled(document, "Token", Token);
  1239. return tzc::json::ValueToJson(document);
  1240. }
  1241. static TZ_BOOL fromJson(const std::string & json, WSSubInfo & value)
  1242. {
  1243. tzc::json::JsonDoc document;
  1244. document.Parse(json.c_str());
  1245. if (document.HasParseError())
  1246. {
  1247. return false;
  1248. }
  1249. value.UName = tzc::json::getFiled(document, "UName", "");
  1250. value.Token = tzc::json::getFiled(document, "Token", "");
  1251. return TRUE;
  1252. }
  1253. };
  1254. template <typename T>
  1255. struct WSMesgInfo {
  1256. TZ_INT Type; // 1:媒体源状态变更
  1257. T MesgBody; // 1:MediaRscState
  1258. std::string toJson() const
  1259. {
  1260. tzc::json::JsonDoc document;
  1261. document.SetObject();
  1262. tzc::json::setFiled(document, "Type", Type);
  1263. tzc::json::setFiledObject(document, "MesgBody", MesgBody);
  1264. return tzc::json::ValueToJson(document);
  1265. }
  1266. static TZ_BOOL fromJson(const std::string & json, WSMesgInfo & value)
  1267. {
  1268. tzc::json::JsonDoc document;
  1269. document.Parse(json.c_str());
  1270. if (document.HasParseError())
  1271. {
  1272. return false;
  1273. }
  1274. value.Type = tzc::json::getFiled(document, "Type", 0);
  1275. tzc::json::ConverObject(document, "MesgBody", value.MesgBody);
  1276. return TRUE;
  1277. }
  1278. };
  1279. NAMESPACE_MAS_END
  1280. #endif