add CompactRecipePoint for loading recipe header data
This commit is contained in:
parent
380eb4cd21
commit
3638909761
8 changed files with 97 additions and 35 deletions
28
src/controllers/CompactRecipeController.ts
Normal file
28
src/controllers/CompactRecipeController.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue