#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 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 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 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 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 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 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 struct PageInfos { PageResult PageInfo; std::list 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 Predicates; std::list 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 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 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