/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lishengyin
 * @Date: 2022-04-19 11:54:52
 * @LastEditors: lishengyin
 * @LastEditTime: 2022-04-28 15:22:45
 */
#include "ApolloKsTemplate.hpp"


/**
 * @description: objectToJson
 * @param {string&} str
 * @return {*}
 */    
void ApolloKsTemplate::ObjectToJson(std::string& str){
    return;
}

/**
 * @description: jsonToObject
 * @param {string&} json
 * @return {*}
 */    
bool ApolloKsTemplate::jsonToObject(const std::string& json){
    
    return true;
}

/**
 * @description: jsonToObject
 * @param {Value&} object
 * @return {*}
 */    
bool ApolloKsTemplate::jsonToObject(const rapidjson::Value& object){
    const auto end = object.MemberEnd();
    if (end == object.FindMember("content") || !object["content"].IsString()) {
        return false;
    } else {
        data = object["content"].GetString();
    }
    return true;
}

/**
 * @description: ObjectToSql
 * @param {string&} sql
 * @return {*}
 */    
bool ApolloKsTemplate::ObjectToSql(std::string& sql){
    SqlStream sqlStream("insert into InsServerDB.`InsKsTemplate` (DESCRIPTIONID, DATA, USERID, ISDELETE)\
        values  ('?','?','?','0')\
        on duplicate key update DESCRIPTIONID=VALUES(DESCRIPTIONID), DATA=VALUES(DATA),\
        USERID=VALUES(USERID), ISDELETE=VALUES(ISDELETE);");
    this->DESCRIPTIONID = ID;
    sqlStream << DESCRIPTIONID  << data  << USERID;
    sql = (std::string)sqlStream;
    return true;
}