24 #include "core/auth/Door_odb.h" 39 return std::make_unique<DoorSearch>(ctx);
48 return d1.
id() < d2.
id();
54 json rep = json::array();
56 odb::transaction t(db->begin());
57 using Query = odb::query<Auth::Door>;
58 std::string partial_name = req.at(
"partial_name");
59 std::set<Auth::Door, DoorComparator> doors;
66 for (
auto i = 0u; i < partial_name.length(); ++i)
68 auto partial_name_copy = partial_name;
69 partial_name_copy[i] = std::toupper(partial_name[i]);
70 Query q(Query::alias.like(
"%" + partial_name_copy +
"%"));
71 auto results = db->query(q);
72 for (
const auto &door : results)
78 Query q(Query::alias.like(
"%" + partial_name +
"%"));
79 auto results = db->query(q);
80 for (
const auto &door : results)
85 for (
const auto &door : doors)
87 json result_json = {{
"id", door.id()}, {
"alias", door.alias()}};
88 rep.push_back(result_json);
96 std::vector<ActionActionParam> perm_;
DoorSearch(RequestContext ctx)
The base class for API method handler implementation.
This is the header file for a generated source file, GitSHA1.cpp.
std::vector< ActionActionParam > required_permission(const json &req) const override
Return a list of "Action" / "ActionParam" that must pass before the request is processed.
std::unique_ptr< MethodHandler > MethodHandlerUPtr
virtual json process_impl(const json &req) override
The API method implementation.
odb::query< Tools::LogEntry > Query
bool operator()(const Auth::Door &d1, const Auth::Door &d2)
All modules that provides features to Leosac shall be in this namespace.
#define ASSERT_LOG(cond, msg)
virtual DoorId id() const override
Holds valuable pointer to provide context to a request.
std::shared_ptr< odb::database > DBPtr
static MethodHandlerUPtr create(RequestContext)