This commit is contained in:
2025-11-25 10:08:34 +03:30
parent a5992d8e29
commit d737b3dc24
7 changed files with 64 additions and 63 deletions
@@ -3,17 +3,33 @@ import { RestaurantsService } from '../providers/restaurants.service';
import { CreateRestaurantDto } from '../dto/create-restaurant.dto';
import { UpdateRestaurantDto } from '../dto/update-restaurant.dto';
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
import { ApiBearerAuth, ApiBody, ApiNotFoundResponse, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import {
ApiBearerAuth,
ApiBody,
ApiNotFoundResponse,
ApiOperation,
ApiParam,
ApiResponse,
ApiTags,
} from '@nestjs/swagger';
import { RestId } from 'src/common/decorators';
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@ApiTags('admin/restaurants')
@Controller('admin/restaurants')
@ApiTags('restaurants')
@Controller()
export class RestaurantsController {
constructor(private readonly restaurantsService: RestaurantsService) {}
@Post()
@Get('public/restaurants/:slug')
@ApiOperation({ summary: 'Get restaurant specification by slug' })
@ApiParam({ name: 'slug', required: true, description: 'Restaurant slug' })
@ApiNotFoundResponse({ description: 'Restaurant not found' })
findBySlug(@Param('slug') slug: string) {
return this.restaurantsService.getRestaurantSpecification(slug);
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Post('admin/restaurants')
@ApiOperation({ summary: 'Create a new restaurant' })
@ApiBody({ type: CreateRestaurantDto })
@ApiResponse({ status: 201, description: 'Restaurant created' })
@@ -28,7 +44,9 @@ export class RestaurantsController {
return this.restaurantsService.findAll();
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@ApiBearerAuth('admin/restaurants')
@ApiOperation({ summary: 'Get restaurant by ID from request' })
@ApiResponse({ status: 200, description: 'Restaurant found' })
@ApiNotFoundResponse({ description: 'Restaurant not found' })
@@ -37,31 +55,34 @@ export class RestaurantsController {
return await this.restaurantsService.findOne(restId);
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Update a restaurant' })
@ApiBody({ type: UpdateRestaurantDto })
@ApiResponse({ status: 200, description: 'Restaurant updated' })
@ApiNotFoundResponse({ type: NotFoundException, description: 'Restaurant not found' })
@Patch(':id')
@Patch('admin/restaurants/:id')
update(@Param('id') id: string, @Body() updateRestaurantDto: UpdateRestaurantDto) {
return this.restaurantsService.update(id, updateRestaurantDto);
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Update a restaurant' })
@ApiBody({ type: UpdateRestaurantDto })
@ApiResponse({ status: 200, description: 'Restaurant updated' })
@ApiNotFoundResponse({ type: NotFoundException, description: 'Restaurant not found' })
@Patch('my-restaurant')
@Patch('admin/restaurants/my-restaurant')
updateMyRestaurant(@RestId() restId: string, @Body() updateRestaurantDto: UpdateRestaurantDto) {
return this.restaurantsService.update(restId, updateRestaurantDto);
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Delete a restaurant' })
@ApiResponse({ status: 200, description: 'Restaurant deleted' })
@ApiNotFoundResponse({ description: 'Restaurant not found' })
@Delete(':id')
@Delete('admin/restaurants/:id')
remove(@Param('id') id: string) {
return this.restaurantsService.remove(id);
}