/*
 * @Description: 
 * @Version: 1.0
 * @Autor: lishengyin
 * @Date: 2022-04-19 11:54:52
 * @LastEditors: lishengyin
 * @LastEditTime: 2022-04-24 17:12:48
 */
#include "ApolloKsWorkloadTemplate.hpp"


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

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

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

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