Multiple implementations of the same back-end application. The aim is to provide quick, side-by-side comparisons of different technologies (languages, frameworks, libraries) while preserving consistent business logic across all implementations.
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.
 
 
 
 
 
 

21 lines
605 B

#include "GetItem.h"
#include "../exceptions/AutoStoreExceptions.h"
namespace nxl::autostore::application {
GetItem::GetItem(IItemRepository& itemRepository)
: itemRepository(itemRepository)
{}
std::optional<domain::Item> 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