fix: move all-sources route before :id to avoid conflict
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 48s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 48s
This commit is contained in:
parent
178666627b
commit
d7647cbc3d
@ -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')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user