码迷,mamicode.com
首页 > 其他好文 > 详细

测试代码

时间:2019-10-16 23:32:38      阅读:101      评论:0      收藏:0      [点我收藏+]

标签:mes   move   row   table   查询   style   data   nts   json   

//在POV.cc中
//4发送查询用户结果
ErrorMessage POV::handleUserSendQuery(rapidjson::Document& doc)
{
    ErrorMessage msg;
    msg.type="UserSend";
    if(!doc.HasMember("name"))
    {
        msg.errcode=343;
        msg.msg="json中不包含name字段";
        std::cout << "msg.errcode:" << msg.errcode << "\nmsg.msg:" << msg.msg << "\n";
        return msg;
    }
    std::string name=doc["name"].GetString();

    if(!blockchain.hasData("name",name,"user"))
    {
        msg.errcode=241;
        msg.msg="数据库中不存在该用户,查询失败";
  std::cout << "msg.errcode:" << msg.errcode << "\nmsg.msg:" << msg.msg << "\n";
        return msg;
    }
    else
    {
        rapidjson::Document& old_data=blockchain.getDataFromDatabase("name",name,"user",true);
        std::cout << "\n找到的用户信息为:";
        old_data[0].RemoveMember("type");
        print_document(old_data[0]);
        msg.errcode=141;
        msg.msg=getDocumentString(old_data[0]);
        msg.is_json=true;
        delete &old_data;
        std::cout << "\nmsg.errcode:" << msg.errcode << "\nmsg.msg:" << msg.msg << "\n";
        return msg;
    }
}

测试代码

标签:mes   move   row   table   查询   style   data   nts   json   

原文地址:https://www.cnblogs.com/annbaek/p/11689214.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!