feat(recipe/application): añadida isFavorite a falsa en la creación de la receta

parent 76cf8a28
......@@ -5,7 +5,6 @@ import com.example.apprecetas.recipe.domain.entity.Recipe;
import com.example.apprecetas.recipe.domain.repository.CreateRecipeRepository;
import com.example.apprecetas.recipe.infrastructure.mapper.RecipeMapper;
import com.example.apprecetas.recipe.infrastructure.repository.mongodb.RecipeDocument;
import com.example.apprecetas.user.domain.repository.ReadUserRepository;
import lombok.RequiredArgsConstructor;
import org.mapstruct.factory.Mappers;
import org.springframework.security.core.context.SecurityContextHolder;
......@@ -17,20 +16,21 @@ public class CreateRecipeUseCaseImpl implements CreateRecipeUseCase {
private final CreateRecipeRepository createRecipeRepository;
private final ReadUserRepository readUserRepository;
private final RecipeMapper mapper = Mappers.getMapper(RecipeMapper.class);
@Override
public Recipe create(Recipe recipe) {
RecipeDocument recipeDocument = mapper.mapDocument(recipe);
// Get idUser from token
// Obtener userId del token
String userId = SecurityContextHolder.getContext().getAuthentication().getName();
// Put userId to recipe
// Añadir userId
recipeDocument.setUserId(userId);
// Poner favorita a falso por defecto
recipeDocument.setFavorite(false);
RecipeDocument savedRecipe = createRecipeRepository.create(recipeDocument);
return mapper.mapDocument(savedRecipe);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment