You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
#pragma once |
|
|
|
#include "webapi/controllers/BaseController.h" |
|
#include "application/commands/AddItem.h" |
|
#include "application/queries/ListItems.h" |
|
#include "application/queries/GetItem.h" |
|
#include "application/commands/DeleteItem.h" |
|
#include "application/interfaces/IAuthService.h" |
|
#include "infrastructure/helpers/JsonItem.h" |
|
#include <httplib.h> |
|
|
|
namespace nxl::autostore::webapi { |
|
|
|
class StoreController : public BaseController |
|
{ |
|
public: |
|
struct Context |
|
{ |
|
application::AddItem addItemUc; |
|
application::ListItems listItemsUc; |
|
application::GetItem getItemUc; |
|
application::DeleteItem deleteItemUc; |
|
application::IAuthService& authService; |
|
}; |
|
|
|
StoreController(Context&& context); |
|
|
|
protected: |
|
std::vector<RouteConfig> getRoutes() const override; |
|
|
|
private: |
|
void addItem(const httplib::Request& req, httplib::Response& res); |
|
void listItems(const httplib::Request& req, httplib::Response& res); |
|
void getItem(const httplib::Request& req, httplib::Response& res); |
|
void deleteItem(const httplib::Request& req, httplib::Response& res); |
|
|
|
void assertUserId(std::optional<domain::User::Id_t> userId) const; |
|
}; |
|
|
|
} // namespace nxl::autostore::webapi
|