import { Controller, Get, UseGuards } from '@nestjs/common';
import {
  ApiTags,
  ApiOperation,
  ApiResponse,
  ApiBearerAuth,
} from '@nestjs/swagger';
import { JwtAuthGuard } from '../guards';
import { CurrentUser } from '../decorators';
import { TeamStatisticsService } from '../../application/services';
import { ProvinceCityDistributionResponseDto } from '../dto';
import { GetProvinceCityDistributionQuery } from '../../application/queries';

@ApiTags('Team Statistics')
@Controller('team-statistics')
export class TeamStatisticsController {
  constructor(private readonly teamStatisticsService: TeamStatisticsService) {}

  @Get('me/distribution')
  @UseGuards(JwtAuthGuard)
  @ApiBearerAuth()
  @ApiOperation({ summary: '获取当前用户团队省市分布' })
  @ApiResponse({ status: 200, type: ProvinceCityDistributionResponseDto })
  async getMyDistribution(
    @CurrentUser('userId') userId: bigint,
  ): Promise<ProvinceCityDistributionResponseDto> {
    const query = new GetProvinceCityDistributionQuery(userId);
    return this.teamStatisticsService.getProvinceCityDistribution(query);
  }
}
