34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common';
|
|
import { BenefitService } from './benefit.service';
|
|
import { JwtAuthGuard, AuthUser } from '../../common/guards/jwt-auth.guard';
|
|
import { CurrentUser } from '../../common/decorators/current-user.decorator';
|
|
|
|
@Controller('benefit')
|
|
@UseGuards(JwtAuthGuard)
|
|
export class BenefitController {
|
|
constructor(private readonly benefitService: BenefitService) {}
|
|
|
|
@Get('coupons')
|
|
coupons(@CurrentUser() user: AuthUser) {
|
|
return this.benefitService.listCoupons(user.actorId);
|
|
}
|
|
|
|
@Get('summary')
|
|
summary(@CurrentUser() user: AuthUser) {
|
|
return this.benefitService.getSummary(user.actorId);
|
|
}
|
|
|
|
@Get('coupons/:id')
|
|
coupon(@CurrentUser() user: AuthUser, @Param('id') id: string) {
|
|
return this.benefitService.getCoupon(user.actorId, BigInt(id));
|
|
}
|
|
|
|
@Get('ledger')
|
|
ledger(@CurrentUser() user: AuthUser, @Query('couponId') couponId?: string) {
|
|
return this.benefitService.getLedger(
|
|
user.actorId,
|
|
couponId ? BigInt(couponId) : undefined,
|
|
);
|
|
}
|
|
}
|