- Fix Next.js build failure: remove duplicate route at (dashboard)/listings/[id] that conflicted with (public)/listings/[id] (same URL path in two route groups) - Fix 772 ESLint errors: auto-fix import ordering (import-x/order), remove unused imports/variables, convert empty interfaces to type aliases, replace require() with ESM imports, fix consistent-type-imports violations - Add CLAUDE.md for developer onboarding documentation - All checks pass: 0 lint errors, typecheck clean, 230 tests passing, build success Co-Authored-By: Paperclip <noreply@paperclip.ing>
64 lines
2.8 KiB
TypeScript
64 lines
2.8 KiB
TypeScript
import {
|
|
Controller,
|
|
Get,
|
|
Query,
|
|
} from '@nestjs/common';
|
|
import { type QueryBus } from '@nestjs/cqrs';
|
|
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
|
|
import { type DistrictStatsDto } from '../../application/queries/get-district-stats/get-district-stats.handler';
|
|
import { GetDistrictStatsQuery } from '../../application/queries/get-district-stats/get-district-stats.query';
|
|
import { type HeatmapDto } from '../../application/queries/get-heatmap/get-heatmap.handler';
|
|
import { GetHeatmapQuery } from '../../application/queries/get-heatmap/get-heatmap.query';
|
|
import { type MarketReportDto } from '../../application/queries/get-market-report/get-market-report.handler';
|
|
import { GetMarketReportQuery } from '../../application/queries/get-market-report/get-market-report.query';
|
|
import { type PriceTrendDto } from '../../application/queries/get-price-trend/get-price-trend.handler';
|
|
import { GetPriceTrendQuery } from '../../application/queries/get-price-trend/get-price-trend.query';
|
|
import { type GetDistrictStatsDto } from '../dto/get-district-stats.dto';
|
|
import { type GetHeatmapDto } from '../dto/get-heatmap.dto';
|
|
import { type GetMarketReportDto } from '../dto/get-market-report.dto';
|
|
import { type GetPriceTrendDto } from '../dto/get-price-trend.dto';
|
|
|
|
@ApiTags('analytics')
|
|
@Controller('analytics')
|
|
export class AnalyticsController {
|
|
constructor(
|
|
private readonly queryBus: QueryBus,
|
|
) {}
|
|
|
|
@Get('market-report')
|
|
@ApiOperation({ summary: 'Get market report for a city' })
|
|
@ApiResponse({ status: 200, description: 'Market report retrieved' })
|
|
async getMarketReport(@Query() dto: GetMarketReportDto): Promise<MarketReportDto> {
|
|
return this.queryBus.execute(
|
|
new GetMarketReportQuery(dto.city, dto.period, dto.propertyType),
|
|
);
|
|
}
|
|
|
|
@Get('price-trend')
|
|
@ApiOperation({ summary: 'Get price trend for a district' })
|
|
@ApiResponse({ status: 200, description: 'Price trend data retrieved' })
|
|
async getPriceTrend(@Query() dto: GetPriceTrendDto): Promise<PriceTrendDto> {
|
|
return this.queryBus.execute(
|
|
new GetPriceTrendQuery(dto.district, dto.city, dto.propertyType, dto.periods),
|
|
);
|
|
}
|
|
|
|
@Get('heatmap')
|
|
@ApiOperation({ summary: 'Get price heatmap for a city' })
|
|
@ApiResponse({ status: 200, description: 'Heatmap data retrieved' })
|
|
async getHeatmap(@Query() dto: GetHeatmapDto): Promise<HeatmapDto> {
|
|
return this.queryBus.execute(
|
|
new GetHeatmapQuery(dto.city, dto.period),
|
|
);
|
|
}
|
|
|
|
@Get('district-stats')
|
|
@ApiOperation({ summary: 'Get statistics by district' })
|
|
@ApiResponse({ status: 200, description: 'District statistics retrieved' })
|
|
async getDistrictStats(@Query() dto: GetDistrictStatsDto): Promise<DistrictStatsDto> {
|
|
return this.queryBus.execute(
|
|
new GetDistrictStatsQuery(dto.city, dto.period),
|
|
);
|
|
}
|
|
}
|