import { Controller, Get, Put, Body, UseGuards, Req } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';
import { DashboardService } from './dashboard.service';

@ApiTags('仪表盘')
@Controller('dashboard')
@UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
export class DashboardController {
  constructor(private dashboardService: DashboardService) {}

  @Get('stats')
  async getStats(@Req() req: any) {
    return this.dashboardService.getStats(req.user.userId);
  }

  @Get('progress')
  async getProgress(@Req() req: any) {
    return this.dashboardService.getProgress(req.user.userId);
  }

  @Get('favorites')
  async getFavorites(@Req() req: any) {
    return this.dashboardService.getFavorites(req.user.userId);
  }

  @Get('profile')
  async getProfile(@Req() req: any) {
    return this.dashboardService.getProfile(req.user.userId);
  }

  @Put('profile')
  async updateProfile(@Req() req: any, @Body() body: { nickname?: string; avatar?: string }) {
    return this.dashboardService.updateProfile(req.user.userId, body);
  }
}
