list of favorites
This commit is contained in:
@@ -56,6 +56,14 @@ export class FoodController {
|
||||
return this.foodsService.toggleFavorite(userId, foodId);
|
||||
}
|
||||
|
||||
@Get('public/foods/favorite')
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiHeader(API_HEADER_SLUG)
|
||||
@ApiBearerAuth()
|
||||
@ApiOperation({ summary: 'get my favorites' })
|
||||
getMyFavorites(@UserId() userId: string) {
|
||||
return this.foodsService.getMyFavorites(userId);
|
||||
}
|
||||
|
||||
/* ---------------------------------- Admin ---------------------------------- */
|
||||
@UseGuards(AdminAuthGuard)
|
||||
|
||||
@@ -260,6 +260,10 @@ export class FoodService {
|
||||
return this.em.persistAndFlush(newFavorite);
|
||||
}
|
||||
|
||||
|
||||
async getMyFavorites(userId: string) {
|
||||
return this.em.find(Favorite, { user: userId }, { populate: ['food'] });
|
||||
}
|
||||
/**
|
||||
* Invalidate cache for restaurant foods
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user