#pragma once #include #include #include "Util/SqlPool.h" using namespace toolkit; using namespace std; class FrameInferData { public: using Ptr = std::shared_ptr; public: int ID; int ClassId; int Num; string Remark; string ImageBase64; string WarningTime; string VideoPath; string attr1; string attr2; string attr3; int Warn = 0; std::string uuid; public: FrameInferData(){} ~FrameInferData(){} std::string ObjectToSql(){ SqlStream sqlStream("insert into gsdDB.`InferData` (ClassId, Num, Remark, ImageBase64, WarningTime, VideoPath, attr1, attr2,attr3,Warn,uuid, ISDELETE)\ values ('?','?','?','?','?', '?','?','?','?','?','?', 0)"); sqlStream << ClassId << Num << Remark << ImageBase64 << WarningTime << VideoPath << attr1 << attr2 << attr3 << Warn << uuid; return (std::string)sqlStream; } // Json转为对象 bool JsonToObject(std::string& json){ rapidjson::Document doc; if (doc.Parse(json.c_str()).HasParseError()) { return false; } // get members const auto end = doc.MemberEnd(); // json_type if(end == doc.FindMember("ID") || !doc["ID"].IsString()) { return false; }else{ ID = atoi(doc["ID"].GetString()); } // json_type if(end == doc.FindMember("ClassId") || !doc["ClassId"].IsString()) { return false; }else{ ClassId = atoi(doc["ClassId"].GetString()); } if (end == doc.FindMember("Num") || !doc["Num"].IsString()) { return false; } else { Num = atoi(doc["Num"].GetString()); } if(end == doc.FindMember("Remark") || !doc["Remark"].IsString()) { return false; }else{ Remark = doc["Remark"].GetString(); } if (end == doc.FindMember("ImageBase64") || !doc["ImageBase64"].IsString()) { return false; } else { ImageBase64 = doc["ImageBase64"].GetString(); } if(end == doc.FindMember("WarningTime") || !doc["WarningTime"].IsString()) { return false; }else{ WarningTime = doc["WarningTime"].GetString(); } if(end == doc.FindMember("VideoPath") || !doc["VideoPath"].IsString()) { return false; }else{ VideoPath = doc["VideoPath"].GetString(); } if(end == doc.FindMember("attr1") || !doc["attr1"].IsString()) { return false; }else{ attr1 = doc["attr1"].IsString(); } if(end == doc.FindMember("attr2") || !doc["attr2"].IsString()) { return false; }else{ attr2 = doc["attr2"].GetString(); } if(end == doc.FindMember("attr3") || !doc["attr3"].IsString()) { return false; }else{ attr2 = doc["attr3"].GetString(); } if(end == doc.FindMember("Warn") || !doc["Warn"].IsString()) { return false; }else{ attr2 = atoi(doc["Warn"].GetString()); } if(end == doc.FindMember("uuid") || !doc["uuid"].IsString()) { return false; }else{ uuid = doc["uuid"].GetString(); } return true; } };