package com.example.hangry; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.Set; @RestController @RequestMapping("/api/group-recipes") @CrossOrigin(origins = "*") public class GroupRecipeController { private final GroupRecipeService groupRecipeService; public GroupRecipeController(GroupRecipeService groupRecipeService) { this.groupRecipeService = groupRecipeService; } @PostMapping("/{groupId}/share/{recipeId}") public ResponseEntity shareRecipe(@PathVariable Long groupId, @PathVariable Long recipeId) { boolean shared = groupRecipeService.shareRecipeWithGroup(groupId, recipeId); return shared ? ResponseEntity.ok("Rezept geteilt") : ResponseEntity.badRequest().body("Fehler beim Teilen"); } @GetMapping("/{groupId}") public ResponseEntity> getGroupRecipes(@PathVariable Long groupId) { return ResponseEntity.ok(groupRecipeService.getGroupRecipes(groupId)); } }