import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; import { OrgModuleGuard } from '../billing/org-module.guard'; import { RequireOrgModule } from '../billing/org-module.decorator'; import { CurrentUser } from '../auth/current-user.decorator'; import type { Actor } from '../common/record-scope'; import { GamificationService } from './gamification.service'; import { RedeemDto, TxQueryDto } from './dto'; @Controller('gamification') @UseGuards(JwtAuthGuard, OrgModuleGuard) @RequireOrgModule('gamification') export class GamificationController { constructor(private readonly game: GamificationService) {} @Get('me') me(@CurrentUser() user: Actor, @Query('period') period?: string) { return this.game.me(user, period); } @Get('pulse') pulse(@CurrentUser() user: Actor, @Query('since') since?: string) { return this.game.pulse(user, since); } @Get('leaderboard') leaderboard( @CurrentUser() user: Actor, @Query('period') period?: string, @Query('limit') limit?: string, ) { return this.game.leaderboard(user, period, limit); } @Get('leaderboard/teams') teams(@CurrentUser() user: Actor, @Query('period') period?: string) { return this.game.teams(user, period); } @Get('transactions') transactions(@CurrentUser() user: Actor, @Query() q: TxQueryDto) { return this.game.transactions(user, q); } @Get('rules') rules(@CurrentUser() user: Actor) { return this.game.publicRules(user); } @Get('feed') feed(@CurrentUser() user: Actor) { return this.game.feed(user); } @Get('achievements') achievements(@CurrentUser() user: Actor, @Query('userId') userId?: string) { return this.game.achievements(user, userId); } @Get('rewards') rewards(@CurrentUser() user: Actor) { return this.game.rewards(user); } @Post('rewards/redeem') redeem(@CurrentUser() user: Actor, @Body() dto: RedeemDto) { return this.game.redeem(user, dto.rewardId, dto.note); } @Get('redemptions') redemptions(@CurrentUser() user: Actor) { return this.game.myRedemptions(user); } }