From b78eeb14ace2bf4799bb819cbbe018f31077a867 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Thu, 25 Dec 2025 11:24:02 +0330 Subject: [PATCH] get restaurant by subscription id --- .../restaurants/controllers/restaurants.controller.ts | 9 +++++++++ src/modules/restaurants/providers/restaurants.service.ts | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/modules/restaurants/controllers/restaurants.controller.ts b/src/modules/restaurants/controllers/restaurants.controller.ts index 48d12c1..2fc94e9 100644 --- a/src/modules/restaurants/controllers/restaurants.controller.ts +++ b/src/modules/restaurants/controllers/restaurants.controller.ts @@ -80,5 +80,14 @@ export class RestaurantsController { return this.restaurantsService.create(createRestaurantDto); } + @UseGuards(SuperAdminAuthGuard) + @ApiBearerAuth() + @ApiOperation({ summary: 'Get restaurant by subscription ID' }) + @ApiParam({ name: 'subscriptionId', required: true, description: 'Subscription ID' }) + @Get('super-admin/restaurants/subscription/:subscriptionId') + findOneBySubscriptionId(@Param('subscriptionId') subscriptionId: string) { + return this.restaurantsService.findOneBySubscriptionId(subscriptionId); + } + } diff --git a/src/modules/restaurants/providers/restaurants.service.ts b/src/modules/restaurants/providers/restaurants.service.ts index 697779b..b1e65f2 100644 --- a/src/modules/restaurants/providers/restaurants.service.ts +++ b/src/modules/restaurants/providers/restaurants.service.ts @@ -64,6 +64,14 @@ export class RestaurantsService { return restaurant; } + async findOneBySubscriptionId(subscriptionId: string): Promise { + const restaurant = await this.restRepository.findOne({ subscriptionId }); + if (!restaurant) { + throw new NotFoundException(RestMessage.NOT_FOUND); + } + return restaurant; + } + async getRestaurantSpecification(slug: string) { const restaurant = await this.findBySlug(slug); return restaurant;