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;