add CompactRecipePoint for loading recipe header data

This commit is contained in:
Anika Raemer 2025-09-28 18:41:56 +02:00
parent 380eb4cd21
commit 3638909761
8 changed files with 97 additions and 35 deletions

View file

@ -0,0 +1,28 @@
import { CompactRecipeDto } from "../dtos/CompactRecipeDto.js";
import { RecipeEntity } from "../entities/RecipeEntity.js";
import { CompactRecipeDtoEntityMapper } from "../mappers/CompactRecipeDtoEntityMapper.js";
import { RecipeRepository } from "../repositories/RecipeRepository.js";
/**
* Responsible for loading recipe header data
*/
export class CompactRecipeController {
constructor(
private repository: RecipeRepository,
private mapper: CompactRecipeDtoEntityMapper
) {}
/**
* Load list of all recipes
* @returns List of all recipes
*/
async getAllCompactRecipes() {
const recipeEntities: RecipeEntity[] = await this.repository.findAll();
// @todo load instruction steps, ingredient groups and ingredients before mapping!
let recipeDtos: CompactRecipeDto[] = [];
recipeEntities.forEach(recipeEntity => {
recipeDtos.push(this.mapper.toDto(recipeEntity));
});
return recipeDtos;
}
}