import { Controller, Get, Query, } from '@nestjs/common'; import { QueryBus } from '@nestjs/cqrs'; import { GetMarketReportQuery } from '../../application/queries/get-market-report/get-market-report.query'; import { GetHeatmapQuery } from '../../application/queries/get-heatmap/get-heatmap.query'; import { GetPriceTrendQuery } from '../../application/queries/get-price-trend/get-price-trend.query'; import { GetDistrictStatsQuery } from '../../application/queries/get-district-stats/get-district-stats.query'; import { GetMarketReportDto } from '../dto/get-market-report.dto'; import { GetHeatmapDto } from '../dto/get-heatmap.dto'; import { GetPriceTrendDto } from '../dto/get-price-trend.dto'; import { GetDistrictStatsDto } from '../dto/get-district-stats.dto'; import { type MarketReportDto } from '../../application/queries/get-market-report/get-market-report.handler'; import { type HeatmapDto } from '../../application/queries/get-heatmap/get-heatmap.handler'; import { type PriceTrendDto } from '../../application/queries/get-price-trend/get-price-trend.handler'; import { type DistrictStatsDto } from '../../application/queries/get-district-stats/get-district-stats.handler'; @Controller('analytics') export class AnalyticsController { constructor( private readonly queryBus: QueryBus, ) {} @Get('market-report') async getMarketReport(@Query() dto: GetMarketReportDto): Promise { return this.queryBus.execute( new GetMarketReportQuery(dto.city, dto.period, dto.propertyType), ); } @Get('price-trend') async getPriceTrend(@Query() dto: GetPriceTrendDto): Promise { return this.queryBus.execute( new GetPriceTrendQuery(dto.district, dto.city, dto.propertyType, dto.periods), ); } @Get('heatmap') async getHeatmap(@Query() dto: GetHeatmapDto): Promise { return this.queryBus.execute( new GetHeatmapQuery(dto.city, dto.period), ); } @Get('district-stats') async getDistrictStats(@Query() dto: GetDistrictStatsDto): Promise { return this.queryBus.execute( new GetDistrictStatsQuery(dto.city, dto.period), ); } }