payment method
This commit is contained in:
@@ -30,38 +30,41 @@ export class RestaurantPaymentMethodController {
|
||||
return this.restaurantPaymentMethodService.create(restId, createRestaurantPaymentMethodDto);
|
||||
}
|
||||
|
||||
@Get(':paymentMethodId')
|
||||
@ApiOperation({ summary: 'Get restaurant payment methods by payment method ID' })
|
||||
@ApiParam({ name: 'paymentMethodId', type: 'string', description: 'Payment method ID' })
|
||||
@Get(':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('paymentMethodId') paymentMethodId: string) {
|
||||
return this.restaurantPaymentMethodService.findByPaymentMethod(paymentMethodId);
|
||||
findByPaymentMethod(@Param('restaurantPaymentMethodId') restaurantPaymentMethodId: string) {
|
||||
return this.restaurantPaymentMethodService.findByPaymentMethod(restaurantPaymentMethodId);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Get a restaurant payment method by ID' })
|
||||
@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);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
@Patch(':restaurantPaymentMethodId')
|
||||
@ApiOperation({ summary: 'Update a restaurant payment method' })
|
||||
@ApiParam({ name: 'id', type: 'string', description: 'Restaurant payment method ID' })
|
||||
@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('id') id: string, @Body() updateRestaurantPaymentMethodDto: UpdateRestaurantPaymentMethodDto) {
|
||||
return this.restaurantPaymentMethodService.update(id, updateRestaurantPaymentMethodDto);
|
||||
update(
|
||||
@Param('restaurantPaymentMethodId') restaurantPaymentMethodId: string,
|
||||
@Body() updateRestaurantPaymentMethodDto: UpdateRestaurantPaymentMethodDto,
|
||||
) {
|
||||
return this.restaurantPaymentMethodService.update(restaurantPaymentMethodId, updateRestaurantPaymentMethodDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
@Delete(':restaurantPaymentMethodId')
|
||||
@ApiOperation({ summary: 'Delete a restaurant payment method' })
|
||||
@ApiParam({ name: 'id', type: 'string', description: 'Restaurant payment method ID' })
|
||||
@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('id') id: string) {
|
||||
return this.restaurantPaymentMethodService.remove(id);
|
||||
remove(@Param('restaurantPaymentMethodId') restaurantPaymentMethodId: string) {
|
||||
return this.restaurantPaymentMethodService.remove(restaurantPaymentMethodId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateRestaurantPaymentMethodDto } from './create-restaurant-payment-method.dto';
|
||||
import { IsString, IsOptional } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class UpdateRestaurantPaymentMethodDto extends PartialType(CreateRestaurantPaymentMethodDto) {
|
||||
@ApiProperty({ description: 'Restaurant payment method ID' })
|
||||
@IsString()
|
||||
id!: string;
|
||||
|
||||
@ApiProperty({ description: 'Restaurant ID', required: false })
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
restaurantId?: string;
|
||||
}
|
||||
|
||||
export class UpdateRestaurantPaymentMethodDto extends PartialType(CreateRestaurantPaymentMethodDto) {}
|
||||
|
||||
@@ -16,8 +16,6 @@ export class RestaurantPaymentMethod extends BaseEntity {
|
||||
@Property({ nullable: true })
|
||||
merchantId?: string;
|
||||
|
||||
@Property({ type: 'decimal', precision: 10, scale: 2, default: 0 })
|
||||
price: number = 0;
|
||||
|
||||
@Property({ type: 'boolean', default: true })
|
||||
isActive: boolean = true;
|
||||
|
||||
@@ -67,9 +67,9 @@ export class RestaurantPaymentMethodService {
|
||||
);
|
||||
}
|
||||
|
||||
async findByPaymentMethod(paymentMethodId: string): Promise<RestaurantPaymentMethod[]> {
|
||||
async findByPaymentMethod(restPaymentMethodId: string): Promise<RestaurantPaymentMethod[]> {
|
||||
return this.restaurantPaymentMethodRepository.find(
|
||||
{ paymentMethod: { id: paymentMethodId } },
|
||||
{ id: restPaymentMethodId },
|
||||
{ populate: ['restaurant', 'paymentMethod'] },
|
||||
);
|
||||
}
|
||||
@@ -91,14 +91,6 @@ export class RestaurantPaymentMethodService {
|
||||
): Promise<RestaurantPaymentMethod> {
|
||||
const restaurantPaymentMethod = await this.findOne(id);
|
||||
|
||||
if (updateRestaurantPaymentMethodDto.restaurantId) {
|
||||
const restaurant = await this.em.findOne(Restaurant, { id: updateRestaurantPaymentMethodDto.restaurantId });
|
||||
if (!restaurant) {
|
||||
throw new NotFoundException(`Restaurant with ID ${updateRestaurantPaymentMethodDto.restaurantId} not found`);
|
||||
}
|
||||
restaurantPaymentMethod.restaurant = restaurant;
|
||||
}
|
||||
|
||||
if (updateRestaurantPaymentMethodDto.paymentMethodId) {
|
||||
const paymentMethod = await this.em.findOne(PaymentMethod, {
|
||||
id: updateRestaurantPaymentMethodDto.paymentMethodId,
|
||||
|
||||
Reference in New Issue
Block a user