其他分享
首页 > 其他分享> > 测试代码

测试代码

作者:互联网

//在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;
    }
}

标签:name,POV,doc,ErrorMessage,msg,测试代码,cout
来源: https://www.cnblogs.com/annbaek/p/11689214.html