新增会话管理功能,包括获取会话列表、获取会话详情和删除会话的API,更新AI教练模块以支持会话模型,调整相关服务和数据传输对象。
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Body, Controller, Post, Res, StreamableFile, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiBody } from '@nestjs/swagger';
|
||||
import { Body, Controller, Delete, Get, Param, Post, Query, Res, StreamableFile, UseGuards } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation, ApiBody, ApiQuery, ApiParam } from '@nestjs/swagger';
|
||||
import { Response } from 'express';
|
||||
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
|
||||
import { CurrentUser } from '../common/decorators/current-user.decorator';
|
||||
@@ -70,6 +70,37 @@ export class AiCoachController {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@Get('conversations')
|
||||
@ApiOperation({ summary: '获取会话列表' })
|
||||
async listConversations(
|
||||
@CurrentUser() user: AccessTokenPayload,
|
||||
@Query() query: { page?: number, pageSize?: number },
|
||||
) {
|
||||
return this.aiCoachService.listConversations(user.sub, { page: query.page, pageSize: query.pageSize });
|
||||
}
|
||||
|
||||
@Get('conversations/:conversationId')
|
||||
@ApiOperation({ summary: '获取会话详情(包含消息)' })
|
||||
@ApiParam({ name: 'conversationId' })
|
||||
async getConversationDetail(
|
||||
@CurrentUser() user: AccessTokenPayload,
|
||||
@Param('conversationId') conversationId: string,
|
||||
) {
|
||||
const data = await this.aiCoachService.getConversationDetail(user.sub, conversationId);
|
||||
return data || { code: 404, message: '会话不存在' };
|
||||
}
|
||||
|
||||
@Delete('conversations/:conversationId')
|
||||
@ApiOperation({ summary: '删除会话(级联删除消息)' })
|
||||
@ApiParam({ name: 'conversationId' })
|
||||
async deleteConversation(
|
||||
@CurrentUser() user: AccessTokenPayload,
|
||||
@Param('conversationId') conversationId: string,
|
||||
) {
|
||||
const ok = await this.aiCoachService.deleteConversation(user.sub, conversationId);
|
||||
return { success: ok };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user