feat(ai-analysis): 接入业务分析接口

This commit is contained in:
2026-07-08 21:49:43 +08:00
parent 7cd18dabac
commit 56c8f59d13
12 changed files with 558 additions and 4 deletions

View File

@@ -1,5 +1,9 @@
import { Body, Controller, Post } from '@nestjs/common';
import { Body, Controller, Headers, Post } from '@nestjs/common';
import { CurrentUser } from '../../common/auth/current-user.decorator';
import type { CurrentUser as ResolvedCurrentUser } from '../../common/auth/auth-context.service';
import { AiService } from './ai.service';
import { BusinessAnalysisService } from './analysis/business-analysis.service';
import { AnalysisDto } from './dto/analysis.dto';
import { DecomposeDto } from './dto/decompose.dto';
import { RiskInterpretDto } from './dto/risk-interpret.dto';
import type {
@@ -7,11 +11,15 @@ import type {
AgentDecomposeError,
AgentRiskInterpretResponse,
AgentRiskInterpretError,
AnalysisResponse,
} from '@ftb/shared';
@Controller('ai')
export class AiController {
constructor(private readonly aiService: AiService) {}
constructor(
private readonly aiService: AiService,
private readonly businessAnalysisService: BusinessAnalysisService,
) {}
@Post('decompose')
async decompose(@Body() dto: DecomposeDto): Promise<AgentDecomposeResponse | AgentDecomposeError> {
@@ -22,4 +30,17 @@ export class AiController {
async interpretRisk(@Body() dto: RiskInterpretDto): Promise<AgentRiskInterpretResponse | AgentRiskInterpretError> {
return this.aiService.interpretRisk(dto);
}
@Post('analysis')
async analyze(
@Body() dto: AnalysisDto,
@CurrentUser() user: ResolvedCurrentUser | null,
@Headers('x-ftb-user-id') headerUserId?: string,
@Headers('x-user-id') legacyHeaderUserId?: string,
): Promise<AnalysisResponse> {
return this.businessAnalysisService.analyze(dto, {
id: user?.id ?? headerUserId ?? legacyHeaderUserId ?? '',
permissions: dto.permissions ?? [],
});
}
}