From 90e2877fabdd367fce7f8ac5d956a202764f1407 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sat, 22 Nov 2025 15:25:39 +0330 Subject: [PATCH] mt restaurent --- .../restaurants/controllers/restaurants.controller.ts | 11 ++++------- .../restaurants/providers/restaurants.service.ts | 10 ++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/modules/restaurants/controllers/restaurants.controller.ts b/src/modules/restaurants/controllers/restaurants.controller.ts index 43cf0fc..e46ef4f 100644 --- a/src/modules/restaurants/controllers/restaurants.controller.ts +++ b/src/modules/restaurants/controllers/restaurants.controller.ts @@ -29,15 +29,12 @@ export class RestaurantsController { } @ApiBearerAuth() - @ApiOperation({ summary: 'Get a restaurant by slug' }) - @ApiResponse({ status: 200, description: 'Restaurant found' }) - @ApiNotFoundResponse({ type: NotFoundException, description: 'Restaurant not found' }) - @Get(':slug') - @ApiOperation({ summary: 'Get a restaurant by slug' }) + @ApiOperation({ summary: 'Get restaurant by ID from request' }) @ApiResponse({ status: 200, description: 'Restaurant found' }) @ApiNotFoundResponse({ description: 'Restaurant not found' }) - findOne(@Param('slug') slug: string) { - return this.restaurantsService.findBySlug(slug); + @Get('my-restaurant') + async findOne(@RestId() restId: string) { + return await this.restaurantsService.findOne(restId); } @ApiBearerAuth() diff --git a/src/modules/restaurants/providers/restaurants.service.ts b/src/modules/restaurants/providers/restaurants.service.ts index 8ef2030..23c4ab0 100644 --- a/src/modules/restaurants/providers/restaurants.service.ts +++ b/src/modules/restaurants/providers/restaurants.service.ts @@ -38,6 +38,16 @@ export class RestaurantsService { return restaurant; } + async findOne(id: string): Promise { + const restaurant = await this.restRepository.findOne({ id }); + + if (!restaurant) { + throw new NotFoundException(RestMessage.NOT_FOUND); + } + + return restaurant; + } + async getRestaurantSpecification(slug: string): Promise { const restaurant = await this.findBySlug(slug);