/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lishengyin
 * @Date: 2022-03-24 15:40:54
 * @LastEditors: lishengyin
 * @LastEditTime: 2022-05-11 16:28:24
 */
#ifndef __HISTORYVIDEO_H_
#define __HISTORYVIDEO_H_

#include <iostream>

using namespace std;


class HistoryVideo
{
public:
    int Id;
    std::string fileName;
    std::string UpdateTime;
public:
    HistoryVideo(){}
    ~HistoryVideo(){}

    /**
     * @description: object to sql
     * @param {*}
     * @return {*}
     */    
    std::string ObjectToSql(){
        SqlStream sqlStream("insert into gsdDB.`HistoryVideo` (fileName, UpdateTime,ISDELETE)\
            values  ('?','?',0)");
        sqlStream << fileName << UpdateTime;
        return (std::string)sqlStream;
    }
    
    /**
     * @description: json to Object
     * @param {string&} json
     * @return {*}
     */    
    bool JsonToObject(std::string& json){
        rapidjson::Document doc;
        if (doc.Parse<rapidjson::kParseCommentsFlag>(json.c_str()).HasParseError()) {
            return false;
        }
        // get members
        const auto end = doc.MemberEnd();

        // json_type
        if(end == doc.FindMember("fileName") || !doc["fileName"].IsString()) {
            return false;
        }else{
            fileName = doc["fileName"].GetString();
        }
        
        // json_type
        if(end == doc.FindMember("UpdateTime") || !doc["UpdateTime"].IsString()) {
            return false;
        }else{
            UpdateTime = doc["UpdateTime"].GetString();
        }
        return true;
    }
};



#endif