19 changed files with 120 additions and 85 deletions
@ -1,18 +0,0 @@
|
||||
#pragma once |
||||
|
||||
#include <string> |
||||
|
||||
namespace nxl { |
||||
namespace autostore { |
||||
namespace domain { |
||||
|
||||
struct User |
||||
{ |
||||
std::string id; |
||||
std::string username; |
||||
std::string passwordHash; |
||||
}; |
||||
|
||||
} // namespace domain
|
||||
} // namespace autostore
|
||||
} // namespace nxl
|
||||
@ -0,0 +1,15 @@
|
||||
#include "AddItem.h" |
||||
#include "domain/polices/ItemExpirationPolicy.h" |
||||
|
||||
namespace nxl::autostore::application { |
||||
|
||||
AddItem::AddItem(IItemRepository& itemRepository) |
||||
: itemRepository(itemRepository) |
||||
{} |
||||
|
||||
void AddItem::execute(domain::Item&& item, const IntPresenter& presenter) |
||||
{ |
||||
// TODO
|
||||
} |
||||
|
||||
} // namespace nxl::autostore::application
|
||||
@ -0,0 +1,25 @@
|
||||
#pragma once |
||||
|
||||
#include "domain/entities/Item.h" |
||||
#include "application/interfaces/IItemRepository.h" |
||||
#include "application/presenters/GenericPresenters.h" |
||||
|
||||
namespace nxl { |
||||
namespace autostore { |
||||
namespace application { |
||||
|
||||
class AddItem |
||||
{ |
||||
public: |
||||
virtual ~AddItem() = default; |
||||
|
||||
AddItem(IItemRepository& itemRepository); |
||||
void execute(domain::Item&& item, const IntPresenter& presenter); |
||||
|
||||
private: |
||||
IItemRepository& itemRepository; |
||||
}; |
||||
|
||||
} // namespace application
|
||||
} // namespace autostore
|
||||
} // namespace nxl
|
||||
@ -0,0 +1,34 @@
|
||||
#pragma once |
||||
|
||||
#include <functional> |
||||
#include <string> |
||||
|
||||
namespace nxl::autostore::application { |
||||
|
||||
struct OpResult |
||||
{ |
||||
bool success; |
||||
std::string message; |
||||
|
||||
bool operator==(const OpResult& other) const |
||||
{ |
||||
return success == other.success && message == other.message; |
||||
} |
||||
}; |
||||
|
||||
struct ErrorResult : public OpResult |
||||
{ |
||||
ErrorResult(std::string message) : OpResult({false, message}) {} |
||||
}; |
||||
|
||||
struct SuccessResult : public OpResult |
||||
{ |
||||
SuccessResult(std::string message) : OpResult({true, message}) {} |
||||
}; |
||||
|
||||
using BoolPresenter = std::function<void(bool)>; |
||||
using IntPresenter = std::function<void(int)>; |
||||
using DoublePresenter = std::function<void(double)>; |
||||
using StringPresenter = std::function<void(std::string)>; |
||||
|
||||
} // namespace nxl::autostore::application
|
||||
@ -1,21 +1,19 @@
|
||||
#pragma once |
||||
|
||||
#include "User.h" |
||||
#include <string> |
||||
#include <chrono> |
||||
|
||||
namespace nxl { |
||||
namespace autostore { |
||||
namespace domain { |
||||
namespace nxl::autostore::domain { |
||||
|
||||
struct Item |
||||
{ |
||||
std::string id; |
||||
using Id_t = std::string; |
||||
Id_t id; |
||||
std::string name; |
||||
std::chrono::system_clock::time_point expirationDate; |
||||
std::string orderUrl; |
||||
std::string userId; |
||||
User::Id_t userId; |
||||
}; |
||||
|
||||
} // namespace domain
|
||||
} // namespace autostore
|
||||
} // namespace nxl
|
||||
} // namespace nxl::autostore::domain
|
||||
@ -0,0 +1,15 @@
|
||||
#pragma once |
||||
|
||||
#include <string> |
||||
|
||||
namespace nxl::autostore::domain { |
||||
|
||||
struct User |
||||
{ |
||||
using Id_t = std::string; |
||||
Id_t id; |
||||
std::string username; |
||||
std::string passwordHash; |
||||
}; |
||||
|
||||
} // namespace nxl::autostore::domain
|
||||
Loading…
Reference in new issue