From 0b62e06646513af0480d283de33a59e17e9ee228 Mon Sep 17 00:00:00 2001 From: Jesse Brault Date: Mon, 29 Dec 2025 12:53:20 -0600 Subject: [PATCH] Move recipes ai-search to POST endpoint. --- .../api/recipe/RecipeController.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/app/mealsmadeeasy/api/recipe/RecipeController.java b/src/main/java/app/mealsmadeeasy/api/recipe/RecipeController.java index 9dda560..1687aad 100644 --- a/src/main/java/app/mealsmadeeasy/api/recipe/RecipeController.java +++ b/src/main/java/app/mealsmadeeasy/api/recipe/RecipeController.java @@ -105,22 +105,26 @@ public class RecipeController { @GetMapping public ResponseEntity> getRecipeInfoViews( Pageable pageable, + @AuthenticationPrincipal User user + ) { + final Slice slice = this.recipeService.getInfoViewsViewableBy(pageable, user); + return ResponseEntity.ok(this.sliceViewService.getSliceView(slice)); + } + + @PostMapping + public ResponseEntity> searchRecipes( @RequestBody(required = false) RecipeSearchBody recipeSearchBody, @AuthenticationPrincipal User user ) { - if (recipeSearchBody != null) { - if (recipeSearchBody.getType() == RecipeSearchBody.Type.AI_PROMPT) { - final RecipeAiSearchSpec spec = this.objectMapper.convertValue( - recipeSearchBody.getData(), RecipeAiSearchSpec.class - ); - final List results = this.recipeService.aiSearch(spec, user); - return ResponseEntity.ok(Map.of("results", results)); - } else { - throw new IllegalArgumentException("Invalid recipeSearchBody type: " + recipeSearchBody.getType()); - } + if (recipeSearchBody.getType() == RecipeSearchBody.Type.AI_PROMPT) { + final RecipeAiSearchSpec spec = this.objectMapper.convertValue( + recipeSearchBody.getData(), + RecipeAiSearchSpec.class + ); + final List results = this.recipeService.aiSearch(spec, user); + return ResponseEntity.ok(Map.of("results", results)); } else { - final Slice slice = this.recipeService.getInfoViewsViewableBy(pageable, user); - return ResponseEntity.ok(this.sliceViewService.getSliceView(slice)); + throw new IllegalArgumentException("Invalid recipeSearchBody type: " + recipeSearchBody.getType()); } }