list of favorites
This commit is contained in:
@@ -56,6 +56,14 @@ export class FoodController {
|
|||||||
return this.foodsService.toggleFavorite(userId, foodId);
|
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 ---------------------------------- */
|
/* ---------------------------------- Admin ---------------------------------- */
|
||||||
@UseGuards(AdminAuthGuard)
|
@UseGuards(AdminAuthGuard)
|
||||||
|
|||||||
@@ -260,6 +260,10 @@ export class FoodService {
|
|||||||
return this.em.persistAndFlush(newFavorite);
|
return this.em.persistAndFlush(newFavorite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async getMyFavorites(userId: string) {
|
||||||
|
return this.em.find(Favorite, { user: userId }, { populate: ['food'] });
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Invalidate cache for restaurant foods
|
* Invalidate cache for restaurant foods
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user