HistoryVideo.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * @Description:
  3. * @Version: 1.0
  4. * @Autor: lishengyin
  5. * @Date: 2022-03-24 15:40:54
  6. * @LastEditors: lishengyin
  7. * @LastEditTime: 2022-05-11 16:28:24
  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. if (doc.Parse<rapidjson::kParseCommentsFlag>(json.c_str()).HasParseError()) {
  41. return false;
  42. }
  43. // get members
  44. const auto end = doc.MemberEnd();
  45. // json_type
  46. if(end == doc.FindMember("fileName") || !doc["fileName"].IsString()) {
  47. return false;
  48. }else{
  49. fileName = doc["fileName"].GetString();
  50. }
  51. // json_type
  52. if(end == doc.FindMember("UpdateTime") || !doc["UpdateTime"].IsString()) {
  53. return false;
  54. }else{
  55. UpdateTime = doc["UpdateTime"].GetString();
  56. }
  57. return true;
  58. }
  59. };
  60. #endif