Move recipes ai-search to POST endpoint.
This commit is contained in:
parent
9f54c63c53
commit
0b62e06646
@ -105,22 +105,26 @@ public class RecipeController {
|
||||
@GetMapping
|
||||
public ResponseEntity<Map<String, Object>> getRecipeInfoViews(
|
||||
Pageable pageable,
|
||||
@AuthenticationPrincipal User user
|
||||
) {
|
||||
final Slice<RecipeInfoView> slice = this.recipeService.getInfoViewsViewableBy(pageable, user);
|
||||
return ResponseEntity.ok(this.sliceViewService.getSliceView(slice));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Map<String, Object>> 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<RecipeInfoView> 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<RecipeInfoView> results = this.recipeService.aiSearch(spec, user);
|
||||
return ResponseEntity.ok(Map.of("results", results));
|
||||
} else {
|
||||
final Slice<RecipeInfoView> slice = this.recipeService.getInfoViewsViewableBy(pageable, user);
|
||||
return ResponseEntity.ok(this.sliceViewService.getSliceView(slice));
|
||||
throw new IllegalArgumentException("Invalid recipeSearchBody type: " + recipeSearchBody.getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user