#include "apis_v1_classify.h" using namespace apis::v1; // Add definition of your processing function here void classify::get(const HttpRequestPtr& req, std::function &&callback){ HttpResponsePtr resp; resp = HttpResponse::newHttpResponse(); HttpResultMsg request; std::string json; request.code = "200"; request.msg = "成功"; request.attr1 = "Animal, Persion"; request.objectToJson(json); resp->setBody(json.c_str()); callback(resp); } /** * @description: 动物识别 * @param {const} HttpRequestPtr * @param {function} & * @param {int} result * @return {*} */ void classify::PostAnimal(const HttpRequestPtr& req, std::function &&callback, int result){ HttpResponsePtr resp; resp = HttpResponse::newHttpResponse(); HttpResultMsg request; std::string json; if(req->getContentType() != ContentType::CT_APPLICATION_X_FORM){ request.code = "202"; request.msg = "失败"; request.attr1 = "ContentType error"; request.objectToJson(json); resp->setBody(json.c_str()); callback(resp); } // 获取Parm if(req->getParameter("image") == "" || req->getParameter("datas") == ""){ request.code = "502"; request.msg = "失败"; request.attr1 = "Parameters are not met."; request.objectToJson(json); resp->setBody(json.c_str()); resp->setStatusCode(k502BadGateway); callback(resp); return; } auto *pluginPtr = app().getPlugin(); auto result_for_future = pluginPtr->CreateTask(req); auto result_ = result_for_future.get(); if(result_.first){ request.code = "200"; request.msg = "成功"; request.attr1 = result_.second; }else{ request.code = "200"; request.msg = "失败"; request.attr1 = result_.second; } request.objectToJson(json); resp->setBody(json.c_str()); resp->setStatusCode(k200OK); callback(resp); } /** * @description: 人体识别 * @param {const} HttpRequestPtr * @param {function} & * @param {int} result * @return {*} */ void classify::PostPersion(const HttpRequestPtr& req, std::function &&callback, int result){ HttpResponsePtr resp; resp = HttpResponse::newHttpResponse(); resp->setBody("PostPersion"); callback(resp); }