feat(ReadRecipe): implementado controlador para leer recetas básico

parent ce340fc0
package com.example.apprecetas.recipe.infrastructure.controller;
import com.example.apprecetas.recipe.application.ReadRecipeUseCase;
import com.example.apprecetas.recipe.infrastructure.controller.dto.RecipeOutputDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/recipe")
public class ReadRecipeController {
@Autowired
private ReadRecipeUseCase service;
@GetMapping("/{id}")
public ResponseEntity<RecipeOutputDto> readById(@PathVariable Long id) {
return ResponseEntity.ok().body(service.readById(id));
}
@GetMapping
public ResponseEntity<List<RecipeOutputDto>> readAll() {
if(service.readAll().isEmpty()) {
return ResponseEntity.noContent().build();
}
return ResponseEntity.ok().body(service.readAll());
}
}
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