HistoryVideo.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-03-24 15:40:54
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-09-28 14:19:55
  8. */
  9. #ifndef __HISTORYVIDEO_H_
  10. #define __HISTORYVIDEO_H_
  11. #include <iostream>
  12. using namespace std;
  13. class HistoryVideo
  14. {
  15. public:
  16. int Id;
  17. std::string fileName;
  18. std::string UpdateTime;
  19. public:
  20. HistoryVideo(){}
  21. ~HistoryVideo(){}
  22. /**
  23. * @description: object to sql
  24. * @param {*}
  25. * @return {*}
  26. */
  27. std::string ObjectToSql(){
  28. SqlStream sqlStream("insert into gsdDB.`HistoryVideo` (fileName, UpdateTime,ISDELETE)\
  29. values ('?','?',0)");
  30. sqlStream << fileName << UpdateTime;
  31. return (std::string)sqlStream;
  32. }
  33. /**
  34. * @description: json to Object
  35. * @param {string&} json
  36. * @return {*}
  37. */
  38. bool JsonToObject(std::string& json){
  39. rapidjson::Document doc;
  40. doc.Parse(json.c_str());
  41. if(!doc.IsObject()){
  42. return false;
  43. }
  44. // get members
  45. const auto end = doc.MemberEnd();
  46. // json_type
  47. if(end == doc.FindMember("fileName") || !doc["fileName"].IsString()) {
  48. return false;
  49. }else{
  50. fileName = doc["fileName"].GetString();
  51. }
  52. // json_type
  53. if(end == doc.FindMember("UpdateTime") || !doc["UpdateTime"].IsString()) {
  54. return false;
  55. }else{
  56. UpdateTime = doc["UpdateTime"].GetString();
  57. }
  58. return true;
  59. }
  60. };
  61. #endif