24 #include "modules/wiegand/WiegandConfig_odb.h" 36 std::vector<WebSockAPI::ICRUDResourceHandler::ActionActionParam>
38 const json &req)
const 40 std::vector<CRUDResourceHandler::ActionActionParam> ret;
48 catch (json::out_of_range &e)
57 hardware_action_param);
61 hardware_action_param);
65 hardware_action_param);
69 hardware_action_param);
79 odb::transaction t(db->begin());
81 auto new_reader = std::make_shared<WiegandReaderConfig>();
84 db->persist(new_reader);
106 using Result = odb::result<WiegandReaderConfig>;
108 odb::transaction t(db->begin());
111 if (!reader_id.is_nil())
120 rep[
"data"] = json::array();
124 for (
const auto &reader : result)
127 if (
ctx_.
session->security_context().check_permission(
143 odb::transaction t(db->begin());
161 odb::transaction t(db->begin());
An instance of this class represents the configuration of one Wiegand reader.
static void unserialize(WiegandReaderConfig &out, const json &in, const SecurityContext &sc)
Hardware::DeviceId device_id
This is the header file for a generated source file, GitSHA1.cpp.
CRUDResourceHandler(RequestContext ctx)
boost::optional< WebSockAPI::json > delete_impl(const WebSockAPI::json &req) override
std::vector< ActionActionParam > required_permission(Verb verb, const WebSockAPI::json &req) const override
virtual UserSecurityContext & security_context() const override
Helper function that returns the security context.
An optional transaction is an object that behave like an odb::transaction if there is no currently ac...
std::unique_ptr< CRUDResourceHandler > CRUDResourceHandlerUPtr
CRUDHandler(const WebSockAPI::RequestContext &ctx)
boost::optional< WebSockAPI::json > update_impl(const WebSockAPI::json &req) override
boost::optional< WebSockAPI::json > read_impl(const WebSockAPI::json &req) override
Thin wrapper around boost::uuids::uuid.
Permissions for hardware devices.
auto find_reader_by_id(const Hardware::DeviceId &id, DBPtr db)
odb::result< Tools::LogEntry > Result
static WebSockAPI::CRUDResourceHandlerUPtr instanciate(WebSockAPI::RequestContext)
Holds valuable pointer to provide context to a request.
std::shared_ptr< odb::database > DBPtr
static json serialize(const WiegandReaderConfig &in, const SecurityContext &sc)
boost::optional< WebSockAPI::json > create_impl(const WebSockAPI::json &req) override