87 lines
4.0 KiB
TypeScript
87 lines
4.0 KiB
TypeScript
import { Controller, Get, Post, Body, Patch, Param, Delete, Query, UseGuards } from '@nestjs/common';
|
|
import { RestaurantPaymentMethodService } from '../services/restaurant-payment-method.service';
|
|
import { CreateRestaurantPaymentMethodDto } from '../dto/create-restaurant-payment-method.dto';
|
|
import { UpdateRestaurantPaymentMethodDto } from '../dto/update-restaurant-payment-method.dto';
|
|
import { RestId } from 'src/common/decorators/rest-id.decorator';
|
|
import {
|
|
ApiTags,
|
|
ApiOperation,
|
|
ApiResponse,
|
|
ApiCreatedResponse,
|
|
ApiOkResponse,
|
|
ApiNotFoundResponse,
|
|
ApiBody,
|
|
ApiParam,
|
|
ApiQuery,
|
|
ApiBearerAuth,
|
|
} from '@nestjs/swagger';
|
|
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
|
|
|
@UseGuards(AdminAuthGuard)
|
|
@ApiBearerAuth()
|
|
@ApiTags('admin/restaurant-payment-methods')
|
|
@Controller('admin/restaurant-payment-methods')
|
|
export class RestaurantPaymentMethodController {
|
|
constructor(private readonly restaurantPaymentMethodService: RestaurantPaymentMethodService) {}
|
|
|
|
@Post()
|
|
@ApiOperation({ summary: 'Create a new restaurant payment method' })
|
|
@ApiBody({ type: CreateRestaurantPaymentMethodDto })
|
|
@ApiCreatedResponse({ description: 'Restaurant payment method created successfully' })
|
|
create(@RestId() restId: string, @Body() createRestaurantPaymentMethodDto: CreateRestaurantPaymentMethodDto) {
|
|
return this.restaurantPaymentMethodService.create(restId, createRestaurantPaymentMethodDto);
|
|
}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'Get all restaurant payment methods' })
|
|
@ApiOkResponse({ description: 'List of all restaurant payment methods' })
|
|
findAll() {
|
|
return this.restaurantPaymentMethodService.findAll();
|
|
}
|
|
|
|
@Get('by-restaurant/:restaurantId')
|
|
@ApiOperation({ summary: 'Get restaurant payment methods by restaurant ID' })
|
|
@ApiParam({ name: 'restaurantId', type: 'string', description: 'Restaurant ID' })
|
|
@ApiOkResponse({ description: 'List of restaurant payment methods for the restaurant' })
|
|
findByRestaurant(@Param('restaurantId') restaurantId: string) {
|
|
return this.restaurantPaymentMethodService.findByRestaurant(restaurantId);
|
|
}
|
|
|
|
@Get('by-payment-method/:paymentMethodId')
|
|
@ApiOperation({ summary: 'Get restaurant payment methods by payment method ID' })
|
|
@ApiParam({ name: 'paymentMethodId', type: 'string', description: 'Payment method ID' })
|
|
@ApiOkResponse({ description: 'List of restaurant payment methods for the payment method' })
|
|
findByPaymentMethod(@Param('paymentMethodId') paymentMethodId: string) {
|
|
return this.restaurantPaymentMethodService.findByPaymentMethod(paymentMethodId);
|
|
}
|
|
|
|
@Get(':id')
|
|
@ApiOperation({ summary: 'Get a restaurant payment method by ID' })
|
|
@ApiParam({ name: 'id', type: 'string', description: 'Restaurant payment method ID' })
|
|
@ApiOkResponse({ description: 'Restaurant payment method found' })
|
|
@ApiNotFoundResponse({ description: 'Restaurant payment method not found' })
|
|
findOne(@Param('id') id: string) {
|
|
return this.restaurantPaymentMethodService.findOne(id);
|
|
}
|
|
|
|
@Patch(':id')
|
|
@ApiOperation({ summary: 'Update a restaurant payment method' })
|
|
@ApiParam({ name: 'id', type: 'string', description: 'Restaurant payment method ID' })
|
|
@ApiBody({ type: UpdateRestaurantPaymentMethodDto })
|
|
@ApiOkResponse({ description: 'Restaurant payment method updated successfully' })
|
|
@ApiNotFoundResponse({ description: 'Restaurant payment method not found' })
|
|
update(@Param('id') id: string, @Body() updateRestaurantPaymentMethodDto: UpdateRestaurantPaymentMethodDto) {
|
|
return this.restaurantPaymentMethodService.update(id, updateRestaurantPaymentMethodDto);
|
|
}
|
|
|
|
@Delete(':id')
|
|
@ApiOperation({ summary: 'Delete a restaurant payment method' })
|
|
@ApiParam({ name: 'id', type: 'string', description: 'Restaurant payment method ID' })
|
|
@ApiOkResponse({ description: 'Restaurant payment method deleted successfully' })
|
|
@ApiNotFoundResponse({ description: 'Restaurant payment method not found' })
|
|
remove(@Param('id') id: string) {
|
|
return this.restaurantPaymentMethodService.remove(id);
|
|
}
|
|
}
|
|
|