1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615 |
- #ifndef __MAS_HTTP_DEFINITION_H
- #define __MAS_HTTP_DEFINITION_H
- #include "MAS_AlgoDef.h"
- #include "TZJson.h"
- NAMESPACE_MAS_BEGIN
- // HTTPURL
- // GET
- #define URL_GET_DB_VERSION "/mas/query/dbversion"
- #define URL_GET_USE_INFO "/mas/query/users"
- #define URL_GET_SYS_CONFIG "/mas/query/sysconfig"
- #define URL_GET_MEDIA_RSC_INFO "/mas/query/mediarscs"
- #define URL_GET_PLAN_INFO "/mas/query/plan"
- #define URL_GET_SERVICE_VERSION "/mas/query/serviceVersion"
- #define URL_GET_WABC_FILE_DOWNLOAD "/mas/download"
- // POST
- #define URL_POST_USE_INFO_COND "/mas/query/users/condition"
- #define URL_POST_MEDIA_SRC_INFO "/mas/query/mediasrcs"
- #define URL_POST_DETECTOR_INFO "/mas/query/detectors"
- #define URL_POST_STRATEGY_INFO "/mas/query/strategies"
- #define URL_POST_SCENE_INFO "/mas/query/scenes"
- #define URL_POST_SCENE_GROUP_INFO "/mas/query/scenegroups"
- #define URL_POST_ADD_USER "/mas/add/user"
- #define URL_POST_UPDATE_USER "/mas/update/user"
- #define URL_POST_DELETE_USER "/mas/delete/user"
- #define URL_POST_EDIT_SYS_CONFIG "/mas/edit/sysconfig"
- #define URL_POST_SYS_CONFIG_KEY "/mas/query/sysconfig/key"
- #define URL_POST_SYS_CONFIG_GROUP "/mas/query/sysconfig/group"
- #define URL_POST_ADD_MEDIA_SRC "/mas/add/mediasrc"
- #define URL_POST_DELETE_MEDIA_SRC "/mas/delete/mediasrc"
- #define URL_POST_EDIT_MEDIA_RSC "/mas/edit/mediarsc"
- #define URL_POST_ADD_MEDIA_RSC "/mas/add/mediarsc"
- #define URL_POST_DELETE_MEDIA_RSC "/mas/delete/mediarsc"
- #define URL_POST_EDIT_DETECTOR_INIT "/mas/edit/detector/initParam"
- #define URL_POST_EDIT_STRAGETY "/mas/edit/strategy"
- #define URL_POST_ADD_SCENE "/mas/add/scene"
- #define URL_POST_EDIT_SCENE "/mas/edit/scene"
- #define URL_POST_DELETE_SCENE "/mas/delete/scene"
- #define URL_POST_SUB_SCENE_DRAW "/mas/subscribe/scene"
- #define URL_POST_ADD_SCENE_GROUP "/mas/add/scenegroup"
- #define URL_POST_EDIT_SCENE_GROUP "/mas/edit/scenegroup"
- #define URL_POST_DELETE_SCENE_GROUP "/mas/delete/scenegroup"
- #define URL_POST_ADD_PLAN "/mas/add/plan"
- #define URL_POST_DELETE_PLAN "/mas/delete/plan"
- #define URL_POST_QUERY_EVENT_RECORD "/mas/query/eventrecord"
- #define URL_POST_QUERY_MEDIA_FILE "/mas/query/mediafile"
- #define URL_POST_QUERY_MEDIA_RECORD "/mas/query/mediarecord"
- #define URL_POST_QUERY_OP_RECORD "/mas/query/oprecord"
- #define URL_POST_QUERY_PERF_RECORD "/mas/query/perfrecord"
- #define URL_POST_PIPE_EXCEPTION "/mas/query/scene/exception"
- #define URL_POST_CTRL_SCENE "/mas/ctrl/scene"
- #define URL_POST_QUERY_SRC_STATE "/mas/query/mediasrcs/state"
- #define URL_POST_WABC_FILE_UPLOAD "/mas/upload"
- // PUT
- #define URL_PUT_REBOOT "/mas/reboot"
- #define URL_PUT_LOGIN "/mas/login"
- #define URL_PUT_LOGOUT "/mas/logout"
- // HTTP Payload Json
- template<typename T>
- struct CommonRequest {
- std::string Token;
- T Params;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Token", Token);
- tzc::json::setFiledParams(document, "Params", Params);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, CommonRequest & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Token = tzc::json::getFiled(document, "Token", "");
- tzc::json::getFiledParams(document, "Params", value.Params);
- return TRUE;
- }
- };
- template<typename T>
- struct CommonResponse {
- TZ_INT Code;
- std::string Msg;
- T Params;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Code", Code);
- tzc::json::setFiled(document, "Msg", Msg);
- tzc::json::setFiledParams(document, "Params", Params);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, CommonResponse & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Code = tzc::json::getFiled(document, "Code", 0);
- value.Msg = tzc::json::getFiled(document, "Msg", "");
- tzc::json::getFiledParams(document, "Params", value.Params);
- return TRUE;
- }
- };
- struct NullStruct {
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, NullStruct & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- return TRUE;
- }
- };
- /*用户信息表*/
- struct UserInfo {
- std::string Username;/*用户名, 主键*/
- std::string Password;/*用户密码,MD5加密*/
- TZ_INT Role;/*用户类型:管理员/用户*/
- TZ_Int64 CreateTime;/*创建时间*/
- TZ_Int64 LoginTime;/*登陆时间*/
- std::string Description;/*描述信息*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Username", Username);
- tzc::json::setFiled(document, "Password", Password);
- tzc::json::setFiled(document, "Role", Role);
- tzc::json::setFiled(document, "CreateTime", CreateTime);
- tzc::json::setFiled(document, "LoginTime", LoginTime);
- tzc::json::setFiled(document, "Description", Description);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, UserInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Username = tzc::json::getFiled(document, "Username", "");
- value.Password = tzc::json::getFiled(document, "Password", "");
- value.Role = tzc::json::getFiled(document, "Role", 0);
- value.CreateTime = tzc::json::getFiled(document, "CreateTime", 0LL);
- value.LoginTime = tzc::json::getFiled(document, "LoginTime", 0LL);
- value.Description = tzc::json::getFiled(document, "Description", "");
- return TRUE;
- }
- };
- /*系统配置表*/
- struct SysConfig {
- std::string ParamKey;/*配置项key,主键*/
- std::string ParamValue;/*配置项value*/
- std::string ParamGroup;/*配置项组*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "ParamKey", ParamKey);
- tzc::json::setFiled(document, "ParamValue", ParamValue);
- tzc::json::setFiled(document, "ParamGroup", ParamGroup);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, SysConfig & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.ParamKey = tzc::json::getFiled(document, "ParamKey", "");
- value.ParamValue = tzc::json::getFiled(document, "ParamValue", "");
- value.ParamGroup = tzc::json::getFiled(document, "ParamGroup", "");
- return TRUE;
- }
- };
- /*媒体资源信息表*/
- struct MediaRscInfo {
- TZ_INT Id;/*唯一标识主键,自增*/
- std::string Name;/*资源名称*/
- TZ_INT SrcId;/*媒体源ID*/
- TZ_INT Idx;/*序号*/
- TZ_INT RscType;/*资源类型:video/audio/mixed*/
- TZ_INT TransFormat;/*数据传输格式PS-RTP/RTP*/
- TZ_INT EncodeFormat;/*数据编码格式h264/h265*/
- TZ_INT StreamType;/*码流类型:主/辅*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "SrcId", SrcId);
- tzc::json::setFiled(document, "Idx", Idx);
- tzc::json::setFiled(document, "RscType", RscType);
- tzc::json::setFiled(document, "TransFormat", TransFormat);
- tzc::json::setFiled(document, "EncodeFormat", EncodeFormat);
- tzc::json::setFiled(document, "StreamType", StreamType);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, MediaRscInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.SrcId = tzc::json::getFiled(document, "SrcId", 0);
- value.Idx = tzc::json::getFiled(document, "Idx", 0);
- value.RscType = tzc::json::getFiled(document, "RscType", 0);
- value.TransFormat = tzc::json::getFiled(document, "TransFormat", 0);
- value.EncodeFormat = tzc::json::getFiled(document, "EncodeFormat", 0);
- value.StreamType = tzc::json::getFiled(document, "StreamType", 0);
- return TRUE;
- }
- };
- /*媒体源表*/
- struct MediaSrcInfo {
- TZ_INT Id;/*唯一标识,主键,自增*/
- std::string Name;/*名称*/
- TZ_INT Type;/*类型:设备/协议/文件*/
- TZ_INT Subtype;/*子类型*/
- std::string Address;/*设备地址/通讯地址/文件路径*/
- TZ_INT Vendor;/*厂商名称*/
- TZ_INT Port;/*设备端口/通讯端口*/
- std::string Username;/*设备登录用户名*/
- std::string Password;/*设备登录用户密码*/
- TZ_INT Mode;/*设备接入方式:SDK/ONVIF*/
- TZ_INT Capability;/*设备通道数*/
- std::string Detail;/*媒体信息,用于协议类型*/
- std::string Description;/*描述信息*/
-
- std::list<MediaRscInfo> MediaRscs;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "Subtype", Subtype);
- tzc::json::setFiled(document, "Address", Address);
- tzc::json::setFiled(document, "Vendor", Vendor);
- tzc::json::setFiled(document, "Port", Port);
- tzc::json::setFiled(document, "Username", Username);
- tzc::json::setFiled(document, "Password", Password);
- tzc::json::setFiled(document, "Mode", Mode);
- tzc::json::setFiled(document, "Capability", Capability);
- tzc::json::setFiled(document, "Detail", Detail);
- tzc::json::setFiled(document, "Description", Description);
- tzc::json::setFiledArrayObject(document, "MediaRscs", MediaRscs);
-
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, MediaSrcInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.Type = tzc::json::getFiled(document, "Type", 0);
- value.Subtype = tzc::json::getFiled(document, "Subtype", 0);
- value.Address = tzc::json::getFiled(document, "Address", "");
- value.Vendor = tzc::json::getFiled(document, "Vendor", 0);
- value.Port = tzc::json::getFiled(document, "Port", 0);
- value.Username = tzc::json::getFiled(document, "Username", "");
- value.Password = tzc::json::getFiled(document, "Password", "");
- value.Mode = tzc::json::getFiled(document, "Mode", 0);
- value.Capability = tzc::json::getFiled(document, "Capability", 0);
- value.Detail = tzc::json::getFiled(document, "Detail", "");
- value.Description = tzc::json::getFiled(document, "Description", "");
- tzc::json::ConverArrayObject(document, "MediaRscs", value.MediaRscs);
- return TRUE;
- }
- };
- /*场景与检测单元关联信息表*/
- struct SceneDetectorInfo {
- TZ_INT Id; /*唯一标识,主键,自增*/
- TZ_INT SceneId; /*场景键值,外键*/
- TZ_INT DetectorId; /*检测单元键值,外键*/
- TZ_INT RscId; /*媒体资源ID,外键*/
- TZ_INT Idx; /*索引id*/
- TZ_INT SIdx; /*上级索引id*/
- std::string DetectorCfg; /*检测单元配置参数Json*/
- std::string Description; /*描述信息*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "SceneId", SceneId);
- tzc::json::setFiled(document, "DetectorId", DetectorId);
- tzc::json::setFiled(document, "RscId", RscId);
- tzc::json::setFiled(document, "Idx", Idx);
- tzc::json::setFiled(document, "SIdx", SIdx);
- tzc::json::setFiled(document, "DetectorCfg", DetectorCfg);
- tzc::json::setFiled(document, "Description", Description);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, SceneDetectorInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
- value.DetectorId = tzc::json::getFiled(document, "DetectorId", 0);
- value.Idx = tzc::json::getFiled(document, "Idx", 0);
- value.SIdx = tzc::json::getFiled(document, "SIdx", 0);
- value.RscId = tzc::json::getFiled(document, "RscId", 0);
- value.DetectorCfg = tzc::json::getFiled(document, "DetectorCfg", "");
- value.Description = tzc::json::getFiled(document, "Description", "");
- return TRUE;
- }
- };
- /*场景信息表*/
- struct SceneInfo {
- TZ_INT Id;/*唯一标识,主键,自增*/
- std::string Name;/*场景名称*/
- std::string Label;/*场景标签*/
- TZ_BOOL Enable;/*是否使能*/
- TZ_INT StrategyId;/*判定策略键值,外键*/
- std::string StrategyCfg;/*判定策略配置参数Json*/
- TZ_BOOL GpuEnable;/*是否开启GPU*/
- std::string Description;/*描述信息*/
- StrategyInfo Strategy;
- std::vector<SceneDetectorInfo> Confs;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "Label", Label);
- tzc::json::setFiled(document, "Enable", Enable);
- tzc::json::setFiled(document, "StrategyId", StrategyId);
- tzc::json::setFiled(document, "StrategyCfg", StrategyCfg);
- tzc::json::setFiled(document, "GpuEnable", GpuEnable);
- tzc::json::setFiled(document, "Description", Description);
- tzc::json::setFiledParams(document, "Strategy", Strategy);
- tzc::json::setFiledParams(document, "Confs", Confs);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, SceneInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.Label = tzc::json::getFiled(document, "Label", "");
- value.Enable = tzc::json::getFiled(document, "Enable", false);
- value.StrategyId = tzc::json::getFiled(document, "StrategyId", 0);
- value.StrategyCfg = tzc::json::getFiled(document, "StrategyCfg", "");
- value.GpuEnable = tzc::json::getFiled(document, "GpuEnable", false);
- value.Description = tzc::json::getFiled(document, "Description", "");
- TZ_BOOL rst;
- rst &= tzc::json::getFiledParams(document, "Strategy", value.Strategy);
- rst &= tzc::json::getFiledParams(document, "Confs", value.Confs);
- return TRUE;
- }
- };
- /*场景组信息表*/
- struct SceneGroup {
- TZ_INT Id;/*唯一标识,主键,自增*/
- std::string Name;/*场景组名称*/
- std::string Label;/*场景组标签*/
- std::vector<SceneInfo> Scenes;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "Label", Label);
- tzc::json::setFiledParams(document, "Scenes", Scenes);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, SceneGroup & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.Label = tzc::json::getFiled(document, "Label", "");
- tzc::json::getFiledParams(document, "Scenes", value.Scenes);
- return TRUE;
- }
- };
- /*计划任务信息表*/
- struct PlanInfo {
- TZ_INT Id;/*唯一标识,主键,自增*/
- TZ_BOOL Reverse;/*反向配置标识*/
- TZ_INT Type;/*计划类型:日计划/周计划/月计划/特殊计划*/
- TZ_Int64 Time;/*时间段使能标识*/
- TZ_INT Day;/*用于周/月计划*/
- std::string Date;/*有效日期*/
- std::string Description;/*描述信息*/
- SceneInfo Scene;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Reverse", Reverse);
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "Time", Time);
- tzc::json::setFiled(document, "Day", Day);
- tzc::json::setFiled(document, "Date", Date);
- tzc::json::setFiled(document, "Description", Description);
- tzc::json::setFiledParams(document, "Scene", Scene);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, PlanInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Reverse = tzc::json::getFiled(document, "Reverse", false);
- value.Type = tzc::json::getFiled(document, "Type", 0);
- value.Time = tzc::json::getFiled(document, "Time", 0LL);
- value.Day = tzc::json::getFiled(document, "Day", 0);
- value.Date = tzc::json::getFiled(document, "Date", "");
- value.Description = tzc::json::getFiled(document, "Description", "");
- TZ_BOOL rst;
- rst&= tzc::json::getFiledParams(document, "Scene", value.Scene);
- return TRUE;
- }
- };
- /*事件记录表*/
- struct EventRecord {
- TZ_INT Id;/*唯一标识,主键,自增*/
- std::string Type;/*事件类型*/
- std::string Name;/*事件名称*/
- std::string Externs;/*额外描述信息*/
- TZ_INT SceneId;/*场景ID*/
- std::string SceneName;/*场景名称*/
- std::string StrategyName;/*判定策略名称*/
- TZ_Int64 BeginTime;/*开始时间戳*/
- TZ_Int64 EndTime;/*结束时间戳*/
- std::string Description;/*描述信息*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "Externs", Externs);
- tzc::json::setFiled(document, "SceneId", SceneId);
- tzc::json::setFiled(document, "SceneName", SceneName);
- tzc::json::setFiled(document, "StrategyName", StrategyName);
- tzc::json::setFiled(document, "BeginTime", BeginTime);
- tzc::json::setFiled(document, "EndTime", EndTime);
- tzc::json::setFiled(document, "Description", Description);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, EventRecord & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Type = tzc::json::getFiled(document, "Type", "");
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.Externs = tzc::json::getFiled(document, "Externs", "");
- value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
- value.SceneName = tzc::json::getFiled(document, "SceneName", "");
- value.StrategyName = tzc::json::getFiled(document, "StrategyName", "");
- value.BeginTime = tzc::json::getFiled(document, "BeginTime", 0LL);
- value.EndTime = tzc::json::getFiled(document, "EndTime", 0LL);
- value.Description = tzc::json::getFiled(document, "Description", "");
- return TRUE;
- }
- };
- /*媒体记录表*/
- struct MediaRecord {
- TZ_INT Id;/*唯一标识,主键,自增*/
- TZ_INT RscId;/*媒体资源ID*/
- std::string Name;/*记录名称*/
- TZ_INT Type;/*记录类型:视频*/
- TZ_Int64 CreateTime;/*创建时间戳*/
- TZ_INT Duration;/*视频文件时长(秒)*/
- TZ_INT Size;/*文件大小(字节)*/
- std::string Path;/*本地文件路径*/
- std::string Description;/*描述信息*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "RscId", RscId);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "CreateTime", CreateTime);
- tzc::json::setFiled(document, "Duration", Duration);
- tzc::json::setFiled(document, "Size", Size);
- tzc::json::setFiled(document, "Path", Path);
- tzc::json::setFiled(document, "Description", Description);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, MediaRecord & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.RscId = tzc::json::getFiled(document, "RscId", 0);
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.Type = tzc::json::getFiled(document, "Type", 0);
- value.CreateTime = tzc::json::getFiled(document, "CreateTime", 0LL);
- value.Duration = tzc::json::getFiled(document, "Duration", 0);
- value.Size = tzc::json::getFiled(document, "Size", 0);
- value.Path = tzc::json::getFiled(document, "Path", "");
- value.Description = tzc::json::getFiled(document, "Description", "");
- return TRUE;
- }
- };
- /*操作记录表*/
- struct OpRecord {
- TZ_INT Id;/*唯一标识,主键,自增*/
- std::string Operation;/*操作*/
- TZ_INT Result;/*操作结果*/
- std::string Username;/*操作用户*/
- std::string UserAddr;/*操作用户登录地址*/
- TZ_Int64 OccurTime;/*时间戳*/
- std::string Description;/*描述信息*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Operation", Operation);
- tzc::json::setFiled(document, "Result", Result);
- tzc::json::setFiled(document, "Username", Username);
- tzc::json::setFiled(document, "UserAddr", UserAddr);
- tzc::json::setFiled(document, "OccurTime", OccurTime);
- tzc::json::setFiled(document, "Description", Description);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, OpRecord & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Operation = tzc::json::getFiled(document, "Operation", "");
- value.Result = tzc::json::getFiled(document, "Result", 0);
- value.Username = tzc::json::getFiled(document, "Username", "");
- value.UserAddr = tzc::json::getFiled(document, "UserAddr", "");
- value.OccurTime = tzc::json::getFiled(document, "OccurTime", 0LL);
- value.Description = tzc::json::getFiled(document, "Description", "");
- return TRUE;
- }
- };
- /*性能记录表*/
- struct PerformanceRecord {
- TZ_INT Id;/*唯一标识,主键,自增*/
- TZ_Int64 RecordTime;/*时间戳*/
- TZ_INT Cpu;/*CPU平均使用率(%)*/
- TZ_INT Memory;/*内存占用率(%)*/
- TZ_INT Nic;/*网卡平均使用率(%)*/
- TZ_INT GpuUtil;/*GPU平均使用率(%)*/
- TZ_INT GpuMemory;/*GPU显存占用率(%)*/
- TZ_INT Disk;/*硬盘使用率(%)*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "RecordTime", RecordTime);
- tzc::json::setFiled(document, "Cpu", Cpu);
- tzc::json::setFiled(document, "Memory", Memory);
- tzc::json::setFiled(document, "Nic", Nic);
- tzc::json::setFiled(document, "GpuUtil", GpuUtil);
- tzc::json::setFiled(document, "GpuMemory", GpuMemory);
- tzc::json::setFiled(document, "Disk", Disk);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, PerformanceRecord & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.RecordTime = tzc::json::getFiled(document, "RecordTime", 0LL);
- value.Cpu = tzc::json::getFiled(document, "Cpu", 0);
- value.Memory = tzc::json::getFiled(document, "Memory", 0);
- value.Nic = tzc::json::getFiled(document, "Nic", 0);
- value.GpuUtil = tzc::json::getFiled(document, "GpuUtil", 0);
- value.GpuMemory = tzc::json::getFiled(document, "GpuMemory", 0);
- value.Disk = tzc::json::getFiled(document, "Disk", 0);
- return TRUE;
- }
- };
- /* 数据库信息 */
- struct DBInfo {
- std::string DbVersion;/*数据库版本号,主键*/
- std::string EditTime;/*数据库创建或更新的时间*/
- std::string Reserved;/*预留字段*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "DbVersion", DbVersion);
- tzc::json::setFiled(document, "EditTime", EditTime);
- tzc::json::setFiled(document, "Reserved", Reserved);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, DBInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.DbVersion = tzc::json::getFiled(document, "DbVersion", "");
- value.EditTime = tzc::json::getFiled(document, "EditTime", "");
- value.Reserved = tzc::json::getFiled(document, "Reserved", "");
- return TRUE;
- }
- };
- /*场景组和场景关联关系表*/
- struct SgroupScene {
- TZ_INT SceneGrpId;/*场景组id和scene_id联合主键*/
- TZ_INT SceneId;/*场景id和scene_grp_id联合主键*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "SceneGrpId", SceneGrpId);
- tzc::json::setFiled(document, "SceneId", SceneId);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, SgroupScene & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.SceneGrpId = tzc::json::getFiled(document, "SceneGrpId", 0);
- value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
- return TRUE;
- }
- };
- /*数据库版本信息*/
- struct DbVersionInfo {
- std::string DbVersion;/*数据库版本号*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "DbVersion", DbVersion);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, DbVersionInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.DbVersion = tzc::json::getFiled(document, "DbVersion", "");
- return TRUE;
- }
- };
- /*通用字符串*/
- struct StringInfo {
- std::string Info;/*内容*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Info", Info);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, StringInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Info = tzc::json::getFiled(document, "Info", "");
- return TRUE;
- }
- };
- /*通用数值*/
- struct NumberInfo {
- TZ_INT Info;/*通用number信息*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Info", Info);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, NumberInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Info = tzc::json::getFiled(document, "Info", 0);
- return TRUE;
- }
- };
- /*媒体源状态*/
- struct MediaRscState {
- TZ_INT Id;/*媒体源id*/
- TZ_BOOL State;/*状态*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "State", State);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, MediaRscState & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.State = tzc::json::getFiled(document, "State", false);
- return TRUE;
- }
- };
- /*翻页查询结果*/
- struct PageResult {
- TZ_INT Total;/*总数*/
- TZ_INT TotalPage;/*总页数*/
- TZ_INT Page;/*页码*/
- TZ_INT Num;/*每页数量*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Total", Total);
- tzc::json::setFiled(document, "TotalPage", TotalPage);
- tzc::json::setFiled(document, "Page", Page);
- tzc::json::setFiled(document, "Num", Num);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, PageResult & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Total = tzc::json::getFiled(document, "Total", 0);
- value.TotalPage = tzc::json::getFiled(document, "TotalPage", 0);
- value.Page = tzc::json::getFiled(document, "Page", 0);
- value.Num = tzc::json::getFiled(document, "Num", 0);
- return TRUE;
- }
- };
- /*数据通道故障信息*/
- struct PipeException {
- TZ_INT SceneID;/*场景ID*/
- TZ_HANDLE Tag;/*通道Tag*/
- TZ_HANDLE SuperTag;/*上级通道Tag*/
- TZ_INT Threshold;/*阈值*/
- TZ_INT Type; /*通道类型:检测单元接收数据通道
- 判定策略接收数据通道
- WSS接收检测结果/数据通道
- RTSP接收数据流通道*/
- TZ_INT Status;/*状态:
- 无数据
- 数据超时
- 正常
- */
- std::string SceneName;/*场景名称*/
- std::string Name;/*通道名称*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "SceneID", SceneID);
- tzc::json::setFiled(document, "Tag", Tag);
- tzc::json::setFiled(document, "SuperTag", SuperTag);
- tzc::json::setFiled(document, "Threshold", Threshold);
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "Status", Status);
- tzc::json::setFiled(document, "SceneName", SceneName);
- tzc::json::setFiled(document, "Name", Name);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, PipeException & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.SceneID = tzc::json::getFiled(document, "SceneID", 0);
- value.Tag = tzc::json::getFiled(document, "Tag", 0);
- value.SuperTag = tzc::json::getFiled(document, "SuperTag", 0);
- value.Threshold = tzc::json::getFiled(document, "Threshold", 0);
- value.Type = tzc::json::getFiled(document, "Type", 0);
- value.Status = tzc::json::getFiled(document, "Status", 0);
- value.SceneName = tzc::json::getFiled(document, "SceneName", "");
- value.Name = tzc::json::getFiled(document, "Name", "");
- return TRUE;
- }
- };
- /*内存使用情况*/
- struct MemoryUsage {
- TZ_FLOAT Size;/*内存占用量(MB)*/
- TZ_FLOAT Proportion;/*内存占用率(%)*/
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Size", Size);
- tzc::json::setFiled(document, "Proportion", Proportion);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, MemoryUsage & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Size = tzc::json::getFiled(document, "Size", 0.0f);
- value.Proportion = tzc::json::getFiled(document, "Proportion", 0.0f);
- return TRUE;
- }
- };
- struct SceneGroupInfo {
- TZ_INT Id;
- std::string Name;
- std::string Label;
- std::list<SceneInfo> Scenes;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Id", Id);
- tzc::json::setFiled(document, "Name", Name);
- tzc::json::setFiled(document, "Label", Label);
- tzc::json::setFiledParams(document, "Scenes", Scenes);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, SceneGroupInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Id = tzc::json::getFiled(document, "Id", 0);
- value.Name = tzc::json::getFiled(document, "Name", "");
- value.Label = tzc::json::getFiled(document, "Label", "");
- tzc::json::getFiledParams(document, "Scenes", value.Scenes);
- return TRUE;
- }
- };
- struct MediaFileCond {
- TZ_INT RscId;
- TZ_INT BeginTime;
- TZ_INT EndTime;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "RscId", RscId);
- tzc::json::setFiled(document, "BeginTime", BeginTime);
- tzc::json::setFiled(document, "EndTime", EndTime);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, MediaFileCond & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.RscId = tzc::json::getFiled(document, "RscId", 0);
- value.BeginTime = tzc::json::getFiled(document, "BeginTime", 0);
- value.EndTime = tzc::json::getFiled(document, "EndTime", 0);
- return TRUE;
- }
- };
- struct MediaFileInfo {
- TZ_INT Type;// EN_MAS_MEDIA_FILE_TYPE
- std::string Url;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiled(document, "Url", Url);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, MediaFileInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Type = tzc::json::getFiled(document, "Type", 0);
- value.Url = tzc::json::getFiled(document, "Url", "");
- return TRUE;
- }
- };
- struct CtrlSceneInfo {
- TZ_INT Open;
- TZ_INT SceneId;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Open", Open);
- tzc::json::setFiled(document, "SceneId", SceneId);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, CtrlSceneInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Open = tzc::json::getFiled(document, "Open", 0);
- value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
- return TRUE;
- }
- };
- struct LoginInfo {
- std::string UName;
- std::string UPwd;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "UName", UName);
- tzc::json::setFiled(document, "UPwd", UPwd);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, LoginInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.UName = tzc::json::getFiled(document, "UName", "");
- value.UPwd = tzc::json::getFiled(document, "UPwd", "");
- return TRUE;
- }
- };
- template<class T>
- struct PageInfos {
- PageResult PageInfo;
- std::list<T> Infos;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiledParams(document, "PageInfo", PageInfo);
- tzc::json::setFiledParams(document, "Infos", Infos);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, PageInfos & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- TZ_BOOL rst = TRUE;
- rst &= tzc::json::getFiledParams(document, "PageInfo", value.PageInfo);
- rst &= tzc::json::getFiledParams(document, "Infos", value.Infos);
- return TRUE;
- }
- };
- struct DevStateInfo {
- TZ_INT SrcId;
- TZ_INT State;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "SrcId", SrcId);
- tzc::json::setFiled(document, "State", State);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, DevStateInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.SrcId = tzc::json::getFiled(document, "SrcId", 0);
- value.State = tzc::json::getFiled(document, "State", 0);
- return TRUE;
- }
- };
- struct WssStreamInfo {
- TZ_INT Seq;
- std::string Data;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Seq", Seq);
- tzc::json::setFiled(document, "Data", Data);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, WssStreamInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Seq = tzc::json::getFiled(document, "Seq", 0);
- value.Data = tzc::json::getFiled(document, "Data", "");
- return TRUE;
- }
- };
- struct PredicateInfo {
- TZ_INT Code;// EN_COMPARE
- std::string Key;
- std::string Value;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Code", Code);
- tzc::json::setFiled(document, "Key", Key);
- tzc::json::setFiled(document, "Value", Value);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, PredicateInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Code = tzc::json::getFiled(document, "Code", 0);
- value.Key = tzc::json::getFiled(document, "Key", "");
- value.Value = tzc::json::getFiled(document, "Value", "");
- return TRUE;
- }
- };
- struct SortInfo {
- std::string Key;
- TZ_INT Value;// EN_ORDER
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Key", Key);
- tzc::json::setFiled(document, "Value", Value);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, SortInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Key = tzc::json::getFiled(document, "Key", "");
- value.Value = tzc::json::getFiled(document, "Value", 0);
- return TRUE;
- }
- };
- struct QueryCondition {
- TZ_INT Page;
- TZ_INT Size;
- std::list<PredicateInfo> Predicates;
- std::list<SortInfo> Sorts;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Page", Page);
- tzc::json::setFiled(document, "Size", Size);
- tzc::json::setFiledParams(document, "Predicates", Predicates);
- tzc::json::setFiledParams(document, "Sorts", Sorts);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, QueryCondition & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.Page = tzc::json::getFiled(document, "Page", 0);
- value.Size = tzc::json::getFiled(document, "Size", 0);
- TZ_BOOL rst = TRUE;
- rst &= tzc::json::getFiledParams(document, "Predicates", value.Predicates);
- rst &= tzc::json::getFiledParams(document, "Sorts", value.Sorts);
- return TRUE;
- }
- };
- struct PlayInfo {
- TZ_INT RscId;
- TZ_Int64 PlayHd;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "RscId", RscId);
- tzc::json::setFiled(document, "PlayHd", PlayHd);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, PlayInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return FALSE;
- }
- value.RscId = tzc::json::getFiled(document, "RscId", 0);
- value.PlayHd = tzc::json::getFiled(document, "PlayHd", 0LL);
- return TRUE;
- }
- };
- struct SubDrawInfo {
- TZ_INT SceneId;
- TZ_BOOL OpFlag;
- std::vector<PlayInfo> PlayHds;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "SceneId", SceneId);
- tzc::json::setFiled(document, "OpFlag", OpFlag);
- tzc::json::setFiledParams(document, "PlayHds", PlayHds);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, SubDrawInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return false;
- }
- value.SceneId = tzc::json::getFiled(document, "SceneId", 0);
- value.OpFlag = tzc::json::getFiled(document, "OpFlag", FALSE);
- tzc::json::getFiledParams(document, "PlayHds", value.PlayHds);
- return TRUE;
- }
- };
- struct WSSubInfo {
- std::string UName; // 用户名
- std::string Token;
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "UName", UName);
- tzc::json::setFiled(document, "Token", Token);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, WSSubInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return false;
- }
- value.UName = tzc::json::getFiled(document, "UName", "");
- value.Token = tzc::json::getFiled(document, "Token", "");
- return TRUE;
- }
- };
- template <typename T>
- struct WSMesgInfo {
- TZ_INT Type; // 1:媒体源状态变更
- T MesgBody; // 1:MediaRscState
- std::string toJson() const
- {
- tzc::json::JsonDoc document;
- document.SetObject();
- tzc::json::setFiled(document, "Type", Type);
- tzc::json::setFiledObject(document, "MesgBody", MesgBody);
- return tzc::json::ValueToJson(document);
- }
- static TZ_BOOL fromJson(const std::string & json, WSMesgInfo & value)
- {
- tzc::json::JsonDoc document;
- document.Parse(json.c_str());
- if (document.HasParseError())
- {
- return false;
- }
- value.Type = tzc::json::getFiled(document, "Type", 0);
- tzc::json::ConverObject(document, "MesgBody", value.MesgBody);
- return TRUE;
- }
- };
- NAMESPACE_MAS_END
- #endif
|