/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lishengyin
 * @Date: 2022-04-24 15:49:12
 * @LastEditors: lishengyin
 * @LastEditTime: 2022-04-26 11:36:27
 */
#include "ApolloKsServersTemplate.hpp"


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

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

/**
 * @description: jsonToObject
 * @param {Value&} object
 * @return {*}
 */    
bool ApolloKsServersTemplate::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 ApolloKsServersTemplate::ObjectToSql(std::string& sql){
    SqlStream sqlStream("insert into InsServerDB.`InsKsServersTemplate` (SERVERID,APOLLONAMESPACEID, DATA, USERID, ISDELETE)\
        values  ('?','?','?','?','0')\
        on duplicate key update SERVERID=VALUES(SERVERID), APOLLONAMESPACEID=VALUES(APOLLONAMESPACEID),\
        DATA=VALUES(DATA) ,USERID=VALUES(USERID), ISDELETE=VALUES(ISDELETE);");

    sqlStream << SERVERID << APOLLONAMESPACEID << data << USERID;
    sql = (std::string)sqlStream;
    return true;
}