feat: add GET /admin-api/knowledge-bases/all-sources
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 47s

This commit is contained in:
wangdl 2026-06-19 15:31:03 +08:00
parent 1abc89be23
commit 178666627b

View File

@ -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 ── // ── Candidates ──
@Get('candidates') @Get('candidates')