import { Controller, Get, Post, UseGuards, Req } from '@nestjs/common'; import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; import { AllowViewer } from '../../common/decorators/allow-viewer.decorator'; import { InvestmentPlanningService } from './investment-planning.service'; @ApiTags('investment-planning') @Controller('investment-planning') @ApiBearerAuth() @UseGuards(JwtAuthGuard) export class InvestmentPlanningController { constructor(private service: InvestmentPlanningService) {} @Get('snapshot') @ApiOperation({ summary: 'Get financial snapshot for investment planning' }) getSnapshot() { return this.service.getFinancialSnapshot(); } @Get('cd-rates') @ApiOperation({ summary: 'Get latest CD rates from market data (backward compat)' }) getCdRates() { return this.service.getCdRates(); } @Get('market-rates') @ApiOperation({ summary: 'Get all market rates grouped by type (CD, Money Market, High Yield Savings)' }) getMarketRates() { return this.service.getMarketRates(); } @Get('saved-recommendation') @ApiOperation({ summary: 'Get the latest saved AI recommendation for this tenant' }) getSavedRecommendation() { return this.service.getSavedRecommendation(); } @Post('recommendations') @ApiOperation({ summary: 'Trigger AI-powered investment recommendations (async — returns immediately)' }) @AllowViewer() triggerRecommendations(@Req() req: any) { return this.service.triggerAIRecommendations(req.user?.sub, req.user?.orgId); } }