payement
This commit is contained in:
@@ -5,7 +5,6 @@ import { UpdatePaymentDto } from '../dto/update-payment.dto';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
ApiResponse,
|
||||
ApiCreatedResponse,
|
||||
ApiOkResponse,
|
||||
ApiNotFoundResponse,
|
||||
@@ -14,55 +13,158 @@ import {
|
||||
ApiBearerAuth,
|
||||
} 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 { RestId } from 'src/common/decorators';
|
||||
import { AuthGuard } from 'src/modules/auth/guards/auth.guard';
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@ApiTags('admin/payments')
|
||||
@Controller('admin/payments')
|
||||
@ApiTags('payments')
|
||||
@Controller()
|
||||
export class PaymentsController {
|
||||
constructor(private readonly paymentsService: PaymentsService) {}
|
||||
constructor(
|
||||
private readonly paymentsService: PaymentsService,
|
||||
private readonly paymentMethodService: PaymentMethodService,
|
||||
private readonly restaurantPaymentMethodService: RestaurantPaymentMethodService,
|
||||
) {}
|
||||
|
||||
@Post()
|
||||
@UseGuards(AuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('public/payments/methods/restaurant')
|
||||
@ApiOperation({ summary: 'Get the restaurant payment methods' })
|
||||
@ApiNotFoundResponse({ description: 'Restaurant payment methods not found' })
|
||||
getTheRestaurantPaymentMethods(@RestId() restId: string) {
|
||||
return this.restaurantPaymentMethodService.findByRestaurant(restId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post('admin/payments')
|
||||
@ApiOperation({ summary: 'Create a new payment' })
|
||||
@ApiBody({ type: CreatePaymentDto })
|
||||
@ApiCreatedResponse({ description: 'Payment created successfully' })
|
||||
create(@Body() createPaymentDto: CreatePaymentDto) {
|
||||
createPayment(@Body() createPaymentDto: CreatePaymentDto) {
|
||||
return this.paymentsService.create(createPaymentDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/payments')
|
||||
@ApiOperation({ summary: 'Get all payments' })
|
||||
@ApiOkResponse({ description: 'List of all payments' })
|
||||
findAll() {
|
||||
findAllPayments() {
|
||||
return this.paymentsService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/payments/:id')
|
||||
@ApiOperation({ summary: 'Get a payment by ID' })
|
||||
@ApiParam({ name: 'id', type: 'number', description: 'Payment ID' })
|
||||
@ApiOkResponse({ description: 'Payment found' })
|
||||
@ApiNotFoundResponse({ description: 'Payment not found' })
|
||||
findOne(@Param('id') id: string) {
|
||||
findOnePayment(@Param('id') id: string) {
|
||||
return this.paymentsService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Patch('admin/payments/:id')
|
||||
@ApiOperation({ summary: 'Update a payment' })
|
||||
@ApiParam({ name: 'id', type: 'number', description: 'Payment ID' })
|
||||
@ApiBody({ type: UpdatePaymentDto })
|
||||
@ApiOkResponse({ description: 'Payment updated successfully' })
|
||||
@ApiNotFoundResponse({ description: 'Payment not found' })
|
||||
update(@Param('id') id: string, @Body() updatePaymentDto: UpdatePaymentDto) {
|
||||
updatePayment(@Param('id') id: string, @Body() updatePaymentDto: UpdatePaymentDto) {
|
||||
return this.paymentsService.update(+id, updatePaymentDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Delete('admin/payments/:id')
|
||||
@ApiOperation({ summary: 'Delete a payment' })
|
||||
@ApiParam({ name: 'id', type: 'number', description: 'Payment ID' })
|
||||
@ApiOkResponse({ description: 'Payment deleted successfully' })
|
||||
@ApiNotFoundResponse({ description: 'Payment not found' })
|
||||
remove(@Param('id') id: string) {
|
||||
removePayment(@Param('id') id: string) {
|
||||
return this.paymentsService.remove(+id);
|
||||
}
|
||||
}
|
||||
|
||||
/** payment methods */
|
||||
@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();
|
||||
}
|
||||
|
||||
@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' })
|
||||
@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);
|
||||
}
|
||||
|
||||
@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')
|
||||
@ApiOperation({ summary: 'Update a restaurant payment method' })
|
||||
@ApiParam({ name: 'restaurantPaymentMethodId', 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('restaurantPaymentMethodId') restaurantPaymentMethodId: string,
|
||||
@Body() updateRestaurantPaymentMethodDto: UpdateRestaurantPaymentMethodDto,
|
||||
) {
|
||||
return this.restaurantPaymentMethodService.update(restaurantPaymentMethodId, updateRestaurantPaymentMethodDto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Delete('admin/payments/methods/restaurant/:restaurantPaymentMethodId')
|
||||
@ApiOperation({ summary: 'Delete a restaurant payment method' })
|
||||
@ApiParam({ name: 'restaurantPaymentMethodId', type: 'string', description: 'Restaurant 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user