payment
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common';
|
||||
import { PaymentsService } from '../services/payments.service';
|
||||
import { CreatePaymentDto } from '../dto/create-payment.dto';
|
||||
import { UpdatePaymentDto } from '../dto/update-payment.dto';
|
||||
import {
|
||||
ApiTags,
|
||||
@@ -14,9 +13,8 @@ import {
|
||||
} from '@nestjs/swagger';
|
||||
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
||||
import { PaymentMethodService } from '../services/payment-method.service';
|
||||
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 { CreatePaymentMethodDto } from '../dto/create-payment-method.dto';
|
||||
import { UpdatePaymentMethodDto } from '../dto/update-payment-method.dto';
|
||||
import { RestId } from 'src/common/decorators';
|
||||
import { AuthGuard } from 'src/modules/auth/guards/auth.guard';
|
||||
|
||||
@@ -26,7 +24,6 @@ export class PaymentsController {
|
||||
constructor(
|
||||
private readonly paymentsService: PaymentsService,
|
||||
private readonly paymentMethodService: PaymentMethodService,
|
||||
private readonly restaurantPaymentMethodService: RestaurantPaymentMethodService,
|
||||
) {}
|
||||
|
||||
@UseGuards(AuthGuard)
|
||||
@@ -35,19 +32,9 @@ export class PaymentsController {
|
||||
@ApiOperation({ summary: 'Get the restaurant payment methods' })
|
||||
@ApiNotFoundResponse({ description: 'Restaurant payment methods not found' })
|
||||
getTheRestaurantPaymentMethods(@RestId() restId: string) {
|
||||
return this.restaurantPaymentMethodService.findByRestaurant(restId);
|
||||
return this.paymentMethodService.findByRestaurant(restId);
|
||||
}
|
||||
|
||||
// @UseGuards(AdminAuthGuard)
|
||||
// @ApiBearerAuth()
|
||||
// @Post('admin/payments')
|
||||
// @ApiOperation({ summary: 'Create a new payment' })
|
||||
// @ApiBody({ type: CreatePaymentDto })
|
||||
// @ApiCreatedResponse({ description: 'Payment created successfully' })
|
||||
// createPayment(@Body() createPaymentDto: CreatePaymentDto) {
|
||||
// return this.paymentsService.create(createPaymentDto);
|
||||
// }
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/payments')
|
||||
@@ -93,78 +80,57 @@ export class PaymentsController {
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/payments/methods')
|
||||
@ApiOperation({ summary: 'Get all payment methods' })
|
||||
@ApiOkResponse({ description: 'List of all payment methods' })
|
||||
findAll() {
|
||||
return this.paymentMethodService.findAll();
|
||||
@ApiOperation({ summary: 'Get restaurant all payment methods' })
|
||||
@ApiOkResponse({ description: 'List of restaurant payment methods' })
|
||||
@ApiNotFoundResponse({ description: 'Restaurant payment methods not found' })
|
||||
findByRestaurant(@RestId() restId: string) {
|
||||
return this.paymentMethodService.findByRestaurant(restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/payments/methods/:id')
|
||||
@ApiOperation({ summary: 'Get a payment method by ID' })
|
||||
@ApiParam({ name: 'id', type: 'string', description: 'Payment method ID' })
|
||||
@Post('admin/payments/methods')
|
||||
@ApiOperation({ summary: 'Create a new restaurant payment method' })
|
||||
@ApiBody({ type: CreatePaymentMethodDto })
|
||||
@ApiCreatedResponse({ description: 'Restaurant payment method created successfully' })
|
||||
createRestaurantPaymentMethod(@RestId() restId: string, @Body() createPaymentMethodDto: CreatePaymentMethodDto) {
|
||||
return this.paymentMethodService.create(restId, createPaymentMethodDto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/payments/methods/:paymentMethodId')
|
||||
@ApiOperation({ summary: 'Get restaurant payment method by ID' })
|
||||
@ApiParam({ name: 'paymentMethodId', type: 'string', description: 'Payment method ID' })
|
||||
@ApiOkResponse({ description: 'Payment method found' })
|
||||
@ApiNotFoundResponse({ description: 'Payment method not found' })
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.paymentMethodService.findOne(id);
|
||||
}
|
||||
|
||||
/** restaurant payment methods */
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post('admin/payments/methods/restaurant')
|
||||
@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);
|
||||
findOneRestaurantPaymentMethod(@Param('paymentMethodId') paymentMethodId: string) {
|
||||
return this.paymentMethodService.findOne(paymentMethodId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/payments/methods/restaurant/:restaurantPaymentMethodId')
|
||||
@ApiOperation({ summary: 'Get restaurant payment method by payment method ID' })
|
||||
@ApiParam({ name: 'restaurantPaymentMethodId', type: 'string', description: 'restaurantPaymentMethodId method ID' })
|
||||
@ApiOkResponse({ description: 'List of restaurant payment methods for the payment method' })
|
||||
findByPaymentMethod(@Param('restaurantPaymentMethodId') restaurantPaymentMethodId: string) {
|
||||
return this.restaurantPaymentMethodService.findByPaymentMethod(restaurantPaymentMethodId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/payments/methods/restaurant')
|
||||
@ApiOperation({ summary: 'Get restaurant all payment methods ' })
|
||||
@ApiOkResponse({ description: 'Restaurant payment method found' })
|
||||
@ApiNotFoundResponse({ description: 'Restaurant payment method not found' })
|
||||
findByRestaurant(@RestId() restId: string) {
|
||||
return this.restaurantPaymentMethodService.findByRestaurant(restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Patch('admin/payments/methods/restaurant/:restaurantPaymentMethodId')
|
||||
@Patch('admin/payments/methods/:paymentMethodId')
|
||||
@ApiOperation({ summary: 'Update a restaurant payment method' })
|
||||
@ApiParam({ name: 'restaurantPaymentMethodId', type: 'string', description: 'Restaurant payment method ID' })
|
||||
@ApiBody({ type: UpdateRestaurantPaymentMethodDto })
|
||||
@ApiParam({ name: 'paymentMethodId', type: 'string', description: 'Payment method ID' })
|
||||
@ApiBody({ type: UpdatePaymentMethodDto })
|
||||
@ApiOkResponse({ description: 'Restaurant payment method updated successfully' })
|
||||
@ApiNotFoundResponse({ description: 'Restaurant payment method not found' })
|
||||
update(
|
||||
@Param('restaurantPaymentMethodId') restaurantPaymentMethodId: string,
|
||||
@Body() updateRestaurantPaymentMethodDto: UpdateRestaurantPaymentMethodDto,
|
||||
updateRestaurantPaymentMethod(
|
||||
@Param('paymentMethodId') paymentMethodId: string,
|
||||
@Body() updatePaymentMethodDto: UpdatePaymentMethodDto,
|
||||
) {
|
||||
return this.restaurantPaymentMethodService.update(restaurantPaymentMethodId, updateRestaurantPaymentMethodDto);
|
||||
return this.paymentMethodService.update(paymentMethodId, updatePaymentMethodDto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Delete('admin/payments/methods/restaurant/:restaurantPaymentMethodId')
|
||||
@Delete('admin/payments/methods/:paymentMethodId')
|
||||
@ApiOperation({ summary: 'Delete a restaurant payment method' })
|
||||
@ApiParam({ name: 'restaurantPaymentMethodId', type: 'string', description: 'Restaurant payment method ID' })
|
||||
@ApiParam({ name: 'paymentMethodId', type: 'string', description: 'Payment method ID' })
|
||||
@ApiOkResponse({ description: 'Restaurant payment method deleted successfully' })
|
||||
@ApiNotFoundResponse({ description: 'Restaurant payment method not found' })
|
||||
remove(@Param('restaurantPaymentMethodId') restaurantPaymentMethodId: string) {
|
||||
return this.restaurantPaymentMethodService.remove(restaurantPaymentMethodId);
|
||||
removeRestaurantPaymentMethod(@Param('paymentMethodId') paymentMethodId: string) {
|
||||
return this.paymentMethodService.remove(paymentMethodId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user