feat(DeleteRecipe): implementado servicio para eliminar recetas básico

parent 6d623c6b
package com.example.apprecetas.recipe.application;
public interface DeleteRecipeUseCase {
void delete(Long id);
}
package com.example.apprecetas.recipe.application.impl;
import com.example.apprecetas.exceptions.EntityNotFoundException;
import com.example.apprecetas.recipe.application.DeleteRecipeUseCase;
import com.example.apprecetas.recipe.domain.repository.DeleteRecipeRepository;
import com.example.apprecetas.recipe.domain.repository.ReadRecipeRepository;
import com.example.apprecetas.recipe.infrastructure.repository.jpa.RecipeJpa;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DeleteRecipeUseCaseImpl implements DeleteRecipeUseCase {
@Autowired
private DeleteRecipeRepository deleteRepository;
@Autowired
private ReadRecipeRepository readRepository;
@Override
public void delete(Long id) {
RecipeJpa recipeJpa = readRepository.readById(id)
.orElseThrow(() -> new EntityNotFoundException("La receta con id " + id + " no existe"));
deleteRepository.delete(recipeJpa);
}
}
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