#include "GetItem.h" #include "../exceptions/AutoStoreExceptions.h" namespace nxl::autostore::application { GetItem::GetItem(IItemRepository& itemRepository) : itemRepository(itemRepository) {} std::optional GetItem::execute(domain::Item::Id_t id, domain::User::Id_t ownerId) { auto item = itemRepository.findById(id); // act as not found when ownerId does not match for security if (!item || item->userId != ownerId) { throw ItemNotFoundException("Item not found"); } return item; } } // namespace nxl::autostore::application