This commit is contained in:
2025-12-06 16:41:13 +03:30
parent 8768cd9961
commit a7d28ab882
@@ -24,6 +24,20 @@ import { RestId } from 'src/common/decorators';
export class CouponController {
constructor(private readonly couponService: CouponService) {}
@Post('public/coupons/validate')
@ApiOperation({ summary: 'Validate a coupon code' })
@ApiBody({ type: ValidateCouponDto })
@ApiOkResponse({ description: 'Coupon validation result' })
@ApiNotFoundResponse({ description: 'Coupon not found or invalid' })
validateCoupon(@Body() validateCouponDto: ValidateCouponDto, @RestId() restId: string) {
return this.couponService.validateCoupon(
validateCouponDto.code,
restId,
validateCouponDto.orderAmount || 0,
validateCouponDto.userId,
);
}
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Post('admin/coupons')
@@ -82,21 +96,9 @@ export class CouponController {
return this.couponService.remove(id);
}
@Post('public/coupons/validate')
@ApiOperation({ summary: 'Validate a coupon code' })
@ApiBody({ type: ValidateCouponDto })
@ApiOkResponse({ description: 'Coupon validation result' })
@ApiNotFoundResponse({ description: 'Coupon not found or invalid' })
validateCoupon(@Body() validateCouponDto: ValidateCouponDto, @RestId() restId: string) {
return this.couponService.validateCoupon(
validateCouponDto.code,
restId,
validateCouponDto.orderAmount || 0,
validateCouponDto.userId,
);
}
@Get('public/coupons/generate-code')
@Get('admin/coupons/generate-code')
@ApiOperation({ summary: 'generate a coupon code' })
generateCouponCode(@RestId() restId: string) {
return this.couponService.generateCouponCode(restId);