Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba María Álvarez
/
AppRecetas
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b3442dbd
authored
Sep 10, 2025
by
Alba María Álvarez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat(recipe): implementada función para leer recetas según su nombre o ingredientes
parent
eea006c6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
0 deletions
src/main/java/com/example/apprecetas/recipe/application/ReadRecipeUseCase.java
src/main/java/com/example/apprecetas/recipe/application/impl/ReadRecipeUseCaseImpl.java
src/main/java/com/example/apprecetas/recipe/domain/repository/ReadRecipeRepository.java
src/main/java/com/example/apprecetas/recipe/infrastructure/controller/ReadRecipeController.java
src/main/java/com/example/apprecetas/recipe/infrastructure/repository/impl/ReadRecipeRepositoryImpl.java
src/main/java/com/example/apprecetas/recipe/infrastructure/repository/mongodb/RecipeRepository.java
src/main/java/com/example/apprecetas/recipe/application/ReadRecipeUseCase.java
View file @
b3442dbd
...
@@ -10,4 +10,6 @@ public interface ReadRecipeUseCase {
...
@@ -10,4 +10,6 @@ public interface ReadRecipeUseCase {
Page
<
Recipe
>
readAllByUser
(
String
userId
,
Pageable
pageable
);
Page
<
Recipe
>
readAllByUser
(
String
userId
,
Pageable
pageable
);
Page
<
Recipe
>
readFavoritesByUser
(
String
userId
,
Pageable
pageable
);
Page
<
Recipe
>
readFavoritesByUser
(
String
userId
,
Pageable
pageable
);
Page
<
Recipe
>
searchRecipes
(
String
userId
,
String
query
,
Pageable
pageable
);
}
}
src/main/java/com/example/apprecetas/recipe/application/impl/ReadRecipeUseCaseImpl.java
View file @
b3442dbd
...
@@ -38,4 +38,10 @@ public class ReadRecipeUseCaseImpl implements ReadRecipeUseCase {
...
@@ -38,4 +38,10 @@ public class ReadRecipeUseCaseImpl implements ReadRecipeUseCase {
return
repository
.
readFavoritesByUser
(
userId
,
pageable
)
return
repository
.
readFavoritesByUser
(
userId
,
pageable
)
.
map
(
mapper:
:
mapDocument
);
.
map
(
mapper:
:
mapDocument
);
}
}
@Override
public
Page
<
Recipe
>
searchRecipes
(
String
userId
,
String
query
,
Pageable
pageable
)
{
return
repository
.
searchRecipes
(
userId
,
query
,
query
,
pageable
)
.
map
(
mapper:
:
mapDocument
);
}
}
}
src/main/java/com/example/apprecetas/recipe/domain/repository/ReadRecipeRepository.java
View file @
b3442dbd
...
@@ -12,4 +12,6 @@ public interface ReadRecipeRepository {
...
@@ -12,4 +12,6 @@ public interface ReadRecipeRepository {
Page
<
RecipeDocument
>
readAllByUser
(
String
userId
,
Pageable
pageable
);
Page
<
RecipeDocument
>
readAllByUser
(
String
userId
,
Pageable
pageable
);
Page
<
RecipeDocument
>
readFavoritesByUser
(
String
userId
,
Pageable
pageable
);
Page
<
RecipeDocument
>
readFavoritesByUser
(
String
userId
,
Pageable
pageable
);
Page
<
RecipeDocument
>
searchRecipes
(
String
userId
,
String
name
,
String
ingredients
,
Pageable
pageable
);
}
}
src/main/java/com/example/apprecetas/recipe/infrastructure/controller/ReadRecipeController.java
View file @
b3442dbd
...
@@ -50,4 +50,16 @@ public class ReadRecipeController {
...
@@ -50,4 +50,16 @@ public class ReadRecipeController {
return
ResponseEntity
.
ok
().
body
(
service
.
readFavoritesByUser
(
userId
,
pageable
).
map
(
mapper:
:
mapList
));
return
ResponseEntity
.
ok
().
body
(
service
.
readFavoritesByUser
(
userId
,
pageable
).
map
(
mapper:
:
mapList
));
}
}
@GetMapping
(
"/search"
)
public
ResponseEntity
<
Page
<
RecipeListDto
>>
searchRecipes
(
@RequestParam
(
required
=
false
)
String
query
,
@RequestParam
(
required
=
false
,
defaultValue
=
"0"
)
int
page
,
@RequestParam
(
required
=
false
,
defaultValue
=
"6"
)
int
size
)
{
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
String
userId
=
SecurityContextHolder
.
getContext
().
getAuthentication
().
getName
();
Page
<
RecipeListDto
>
dtoPage
=
service
.
searchRecipes
(
userId
,
query
,
pageable
).
map
(
mapper:
:
mapList
);
return
ResponseEntity
.
ok
().
body
(
dtoPage
);
}
}
}
src/main/java/com/example/apprecetas/recipe/infrastructure/repository/impl/ReadRecipeRepositoryImpl.java
View file @
b3442dbd
...
@@ -30,4 +30,9 @@ public class ReadRecipeRepositoryImpl implements ReadRecipeRepository {
...
@@ -30,4 +30,9 @@ public class ReadRecipeRepositoryImpl implements ReadRecipeRepository {
public
Page
<
RecipeDocument
>
readFavoritesByUser
(
String
userId
,
Pageable
pageable
)
{
public
Page
<
RecipeDocument
>
readFavoritesByUser
(
String
userId
,
Pageable
pageable
)
{
return
recipeRepository
.
findByUserIdAndIsFavoriteTrue
(
userId
,
pageable
);
return
recipeRepository
.
findByUserIdAndIsFavoriteTrue
(
userId
,
pageable
);
}
}
@Override
public
Page
<
RecipeDocument
>
searchRecipes
(
String
userId
,
String
name
,
String
ingredients
,
Pageable
pageable
)
{
return
recipeRepository
.
findByUserIdAndNameIgnoreCaseContainingOrIngredientsNameIgnoreCaseContaining
(
userId
,
name
,
ingredients
,
pageable
);
}
}
}
src/main/java/com/example/apprecetas/recipe/infrastructure/repository/mongodb/RecipeRepository.java
View file @
b3442dbd
...
@@ -8,4 +8,6 @@ public interface RecipeRepository extends MongoRepository<RecipeDocument, String
...
@@ -8,4 +8,6 @@ public interface RecipeRepository extends MongoRepository<RecipeDocument, String
Page
<
RecipeDocument
>
findByUserId
(
String
userId
,
Pageable
pageable
);
Page
<
RecipeDocument
>
findByUserId
(
String
userId
,
Pageable
pageable
);
Page
<
RecipeDocument
>
findByUserIdAndIsFavoriteTrue
(
String
userId
,
Pageable
pageable
);
Page
<
RecipeDocument
>
findByUserIdAndIsFavoriteTrue
(
String
userId
,
Pageable
pageable
);
Page
<
RecipeDocument
>
findByUserIdAndNameIgnoreCaseContainingOrIngredientsNameIgnoreCaseContaining
(
String
userId
,
String
name
,
String
ingredients
,
Pageable
pageable
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment