Complete backend MVP
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#include "controllers/PublicController.h"
|
||||
|
||||
#include "common/Http.h"
|
||||
#include "services/ReportService.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
using drogon::HttpResponsePtr;
|
||||
|
||||
namespace
|
||||
{
|
||||
std::optional<std::string> queryValue(const drogon::HttpRequestPtr &req,
|
||||
const std::string &key)
|
||||
{
|
||||
const auto value = req->getParameter(key);
|
||||
if (value.empty())
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void PublicController::openDataReports(
|
||||
const drogon::HttpRequestPtr &req,
|
||||
std::function<void(const HttpResponsePtr &)> &&callback)
|
||||
{
|
||||
visione::services::ReportService service;
|
||||
callback(visione::http::json(service.openDataReports(queryValue(req, "page"),
|
||||
queryValue(req, "per_page"))));
|
||||
}
|
||||
Reference in New Issue
Block a user