24 #include "core/auth/AccessPoint_odb.h" 39 return std::make_unique<AccessPointSearch>(ctx);
48 return ap1.
id() < ap2.
id();
54 json rep = json::array();
56 odb::transaction t(db->begin());
57 using Query = odb::query<Auth::AccessPoint>;
58 std::string partial_name = req.at(
"partial_name");
59 std::set<Auth::AccessPoint, AccessPointComparator> access_points;
63 for (
auto i = 0u; i < partial_name.length(); ++i)
65 auto partial_name_copy = partial_name;
66 partial_name_copy[i] = std::toupper(partial_name[i]);
67 Query q(Query::alias.like(
"%" + partial_name_copy +
"%"));
68 auto results = db->query(q);
69 for (
const auto &ap : results)
71 access_points.insert(ap);
75 Query q(Query::alias.like(
"%" + partial_name +
"%"));
76 auto results = db->query(q);
77 for (
const auto &ap : results)
79 access_points.insert(ap);
82 for (
const auto &ap : access_points)
84 json result_json = {{
"id", ap.id()}, {
"alias", ap.alias()}};
85 rep.push_back(result_json);
91 std::vector<ActionActionParam>
94 std::vector<ActionActionParam> perm_;
virtual json process_impl(const json &req) override
The API method implementation.
The base class for API method handler implementation.
AccessPointSearch(RequestContext ctx)
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.
static MethodHandlerUPtr create(RequestContext)
std::unique_ptr< MethodHandler > MethodHandlerUPtr
odb::query< Tools::LogEntry > Query
All modules that provides features to Leosac shall be in this namespace.
bool operator()(const Auth::AccessPoint &ap1, const Auth::AccessPoint &ap2)
#define ASSERT_LOG(cond, msg)
AccessPointId id() const override
Holds valuable pointer to provide context to a request.
std::shared_ptr< odb::database > DBPtr