fix: add enrichWithNames to chat sessions API
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 46s
This commit is contained in:
parent
9a392ba274
commit
1abc89be23
@ -2,6 +2,7 @@ import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common';
|
|||||||
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';
|
||||||
import { PrismaService } from '../../infrastructure/database/prisma.service';
|
import { PrismaService } from '../../infrastructure/database/prisma.service';
|
||||||
import { AdminAuthGuard } from '../../common/guards/admin-auth.guard';
|
import { AdminAuthGuard } from '../../common/guards/admin-auth.guard';
|
||||||
|
import { enrichWithNames } from '../../common/helpers/name-resolver';
|
||||||
import { AdminRolesGuard } from '../../common/guards/admin-roles.guard';
|
import { AdminRolesGuard } from '../../common/guards/admin-roles.guard';
|
||||||
import { AdminRoles } from '../../common/decorators/admin-roles.decorator';
|
import { AdminRoles } from '../../common/decorators/admin-roles.decorator';
|
||||||
import type { AdminRole } from '../../common/types/admin-role.enum';
|
import type { AdminRole } from '../../common/types/admin-role.enum';
|
||||||
@ -17,12 +18,13 @@ export class AdminRagChatController {
|
|||||||
@AdminRoles('ADMIN' as AdminRole)
|
@AdminRoles('ADMIN' as AdminRole)
|
||||||
@ApiOperation({ summary: '用户对话列表' })
|
@ApiOperation({ summary: '用户对话列表' })
|
||||||
async sessions(@Query('userId') userId?: string) {
|
async sessions(@Query('userId') userId?: string) {
|
||||||
return this.prisma.chatSession.findMany({
|
const items = await this.prisma.chatSession.findMany({
|
||||||
where: userId ? { userId } : undefined,
|
where: userId ? { userId } : undefined,
|
||||||
orderBy: { updatedAt: 'desc' },
|
orderBy: { updatedAt: 'desc' },
|
||||||
take: 100,
|
take: 100,
|
||||||
include: { _count: { select: { messages: true } } },
|
include: { _count: { select: { messages: true } } },
|
||||||
});
|
});
|
||||||
|
return enrichWithNames(this.prisma, items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('sessions/:id/messages')
|
@Get('sessions/:id/messages')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user