diff --git a/src/modules/admin-knowledge/admin-knowledge.controller.ts b/src/modules/admin-knowledge/admin-knowledge.controller.ts index ae699f6..8d0ad07 100644 --- a/src/modules/admin-knowledge/admin-knowledge.controller.ts +++ b/src/modules/admin-knowledge/admin-knowledge.controller.ts @@ -28,6 +28,31 @@ export class AdminKnowledgeController { const enriched = await enrichWithNames(this.prisma, items); return { items: enriched, total, page: p, limit: l, totalPages: Math.ceil(total / l) }; } + // ══ All Sources (must be before :id to avoid route conflict) ══ + + @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) }; + } + @Get(':id') @ApiOperation({ summary: '知识库详情' }) async detail(@Param('id') id: string) { @@ -69,31 +94,6 @@ 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')