From 178666627b67a7f851da654e7f636e044403b1d7 Mon Sep 17 00:00:00 2001 From: wangdl Date: Fri, 19 Jun 2026 15:31:03 +0800 Subject: [PATCH] feat: add GET /admin-api/knowledge-bases/all-sources --- .../admin-knowledge.controller.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/modules/admin-knowledge/admin-knowledge.controller.ts b/src/modules/admin-knowledge/admin-knowledge.controller.ts index 28031c3..ae699f6 100644 --- a/src/modules/admin-knowledge/admin-knowledge.controller.ts +++ b/src/modules/admin-knowledge/admin-knowledge.controller.ts @@ -69,6 +69,31 @@ export class AdminKnowledgeController { }); } + // ── All Sources (global admin list) ── + + @Get('all-sources') + @ApiOperation({ summary: '所有资料来源列表(管理员全局视图)' }) + async allSources( + @Query('page') page = '1', + @Query('limit') limit = '20', + @Query('knowledgeBaseId') kbId?: string, + @Query('parseStatus') parseStatus?: string, + @Query('search') search?: string, + ) { + const p = parseInt(page), l = parseInt(limit); + const where: any = { deletedAt: null }; + if (kbId) where.knowledgeBaseId = kbId; + if (parseStatus) where.parseStatus = parseStatus; + if (search) where.originalFilename = { contains: search }; + + const [items, total] = await Promise.all([ + this.prisma.knowledgeSource.findMany({ where, orderBy: { createdAt: 'desc' }, skip: (p - 1) * l, take: l }), + this.prisma.knowledgeSource.count({ where }), + ]); + const enriched = await enrichWithNames(this.prisma, items); + return { items: enriched, total, page: p, limit: l, totalPages: Math.ceil(total / l) }; + } + // ── Candidates ── @Get('candidates')