Files
dmenu-api/src/modules/restaurants/controllers/restaurant-shipment-method.controller.ts
T
2025-11-23 09:46:24 +03:30

85 lines
3.5 KiB
TypeScript

import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
import {
ApiTags,
ApiOperation,
ApiCreatedResponse,
ApiOkResponse,
ApiNotFoundResponse,
ApiParam,
ApiBody,
ApiBearerAuth,
} from '@nestjs/swagger';
import { RestaurantShipmentMethodService } from '../providers/restaurant-shipment-method.service';
import { CreateRestaurantShipmentMethodDto } from '../dto/create-restaurant-shipment-method.dto';
import { UpdateRestaurantShipmentMethodDto } from '../dto/update-restaurant-shipment-method.dto';
import { RestaurantShipmentMethod } from '../entities/restaurant-shipment-method.entity';
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
import { RestId } from 'src/common/decorators/rest-id.decorator';
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@ApiTags('admin/restaurant-shipment-methods')
@Controller('admin/restaurant-shipment-methods')
export class RestaurantShipmentMethodController {
constructor(private readonly restaurantShipmentMethodService: RestaurantShipmentMethodService) {}
@Post()
@ApiOperation({ summary: 'Create a new restaurant shipment method' })
@ApiBody({ type: CreateRestaurantShipmentMethodDto })
@ApiCreatedResponse({
description: 'Restaurant shipment method created successfully',
type: RestaurantShipmentMethod,
})
create(@Body() createDto: CreateRestaurantShipmentMethodDto, @RestId() restId: string) {
return this.restaurantShipmentMethodService.create(restId, createDto);
}
@Get()
@ApiOperation({ summary: 'Get all restaurant shipment methods' })
@ApiOkResponse({
description: 'List of restaurant shipment methods',
type: [RestaurantShipmentMethod],
})
findAll(@RestId() restId: string) {
return this.restaurantShipmentMethodService.findAll(restId);
}
@Get(':shipmentMethodId')
@ApiOperation({ summary: 'Get a restaurant shipment method by shipment method ID' })
@ApiParam({ name: 'shipmentMethodId', description: 'Shipment method ID' })
@ApiOkResponse({
description: 'Restaurant shipment method details',
type: RestaurantShipmentMethod,
})
@ApiNotFoundResponse({ description: 'Restaurant shipment method not found' })
findOne(@Param('shipmentMethodId') shipmentMethodId: string, @RestId() restId: string) {
return this.restaurantShipmentMethodService.findOne(restId, shipmentMethodId);
}
@Patch(':shipmentMethodId')
@ApiOperation({ summary: 'Update a restaurant shipment method' })
@ApiParam({ name: 'shipmentMethodId', description: 'Shipment method ID' })
@ApiBody({ type: UpdateRestaurantShipmentMethodDto })
@ApiOkResponse({
description: 'Restaurant shipment method updated successfully',
type: RestaurantShipmentMethod,
})
@ApiNotFoundResponse({ description: 'Restaurant shipment method not found' })
update(
@Param('shipmentMethodId') shipmentMethodId: string,
@Body() updateDto: UpdateRestaurantShipmentMethodDto,
@RestId() restId: string,
) {
return this.restaurantShipmentMethodService.update(restId, shipmentMethodId, updateDto);
}
@Delete(':shipmentMethodId')
@ApiOperation({ summary: 'Delete a restaurant shipment method' })
@ApiParam({ name: 'shipmentMethodId', description: 'Shipment method ID' })
@ApiOkResponse({ description: 'Restaurant shipment method deleted successfully' })
@ApiNotFoundResponse({ description: 'Restaurant shipment method not found' })
remove(@Param('shipmentMethodId') shipmentMethodId: string, @RestId() restId: string) {
return this.restaurantShipmentMethodService.remove(restId, shipmentMethodId);
}
}