diff --git a/mateclaw-server/src/main/java/vip/mate/wiki/controller/WikiController.java b/mateclaw-server/src/main/java/vip/mate/wiki/controller/WikiController.java index fff1216c..63d7d46e 100644 --- a/mateclaw-server/src/main/java/vip/mate/wiki/controller/WikiController.java +++ b/mateclaw-server/src/main/java/vip/mate/wiki/controller/WikiController.java @@ -186,12 +186,33 @@ public class WikiController { // ==================== Raw Materials ==================== @RequireWorkspaceRole("viewer") - @Operation(summary = "获取原始材料列表") + @Operation(summary = "获取原始材料列表(含每条材料生成的页面数)") @GetMapping("/knowledge-bases/{kbId}/raw") - public R> listRaw(@PathVariable Long kbId, - @RequestHeader(value = "X-Workspace-Id", required = false) Long workspaceId) { + public R>> listRaw(@PathVariable Long kbId, + @RequestHeader(value = "X-Workspace-Id", required = false) Long workspaceId) { verifyKBWorkspace(kbId, workspaceId); - return R.ok(rawService.listByKbId(kbId)); + List raws = rawService.listByKbId(kbId); + List> result = new java.util.ArrayList<>(raws.size()); + for (WikiRawMaterialEntity raw : raws) { + Map item = new LinkedHashMap<>(); + // Serialize all entity fields via Jackson-friendly approach + item.put("id", raw.getId()); + item.put("kbId", raw.getKbId()); + item.put("title", raw.getTitle()); + item.put("sourceType", raw.getSourceType()); + item.put("processingStatus", raw.getProcessingStatus()); + item.put("processingDetail", raw.getProcessingDetail()); + item.put("progressPhase", raw.getProgressPhase()); + item.put("progressDone", raw.getProgressDone()); + item.put("progressTotal", raw.getProgressTotal()); + item.put("contentHash", raw.getContentHash()); + item.put("createTime", raw.getCreateTime()); + item.put("updateTime", raw.getUpdateTime()); + // Enriched field: page count derived from this raw material + item.put("pageCount", pageService.countBySourceRawId(kbId, raw.getId())); + result.add(item); + } + return R.ok(result); } @RequireWorkspaceRole("member") diff --git a/mateclaw-server/src/main/java/vip/mate/wiki/service/WikiPageService.java b/mateclaw-server/src/main/java/vip/mate/wiki/service/WikiPageService.java index c85ac8b7..616fdcb4 100644 --- a/mateclaw-server/src/main/java/vip/mate/wiki/service/WikiPageService.java +++ b/mateclaw-server/src/main/java/vip/mate/wiki/service/WikiPageService.java @@ -406,6 +406,18 @@ public class WikiPageService { .eq(WikiPageEntity::getKbId, kbId))); } + /** + * Count wiki pages derived from a specific raw material. + * Uses sourceRawIds JSON array field (e.g. "[123]" or "[123,456]"). + */ + public int countBySourceRawId(Long kbId, Long rawId) { + // Use LIKE search on sourceRawIds JSON — works for both single and multi-source pages + return Math.toIntExact(pageMapper.selectCount( + new LambdaQueryWrapper() + .eq(WikiPageEntity::getKbId, kbId) + .like(WikiPageEntity::getSourceRawIds, rawId.toString()))); + } + /** * 从 Markdown 内容中提取 [[links]] 并返回 JSON 数组 */ diff --git a/mateclaw-ui/src/i18n/locales/en-US.ts b/mateclaw-ui/src/i18n/locales/en-US.ts index a0ab9c6b..b5148abc 100644 --- a/mateclaw-ui/src/i18n/locales/en-US.ts +++ b/mateclaw-ui/src/i18n/locales/en-US.ts @@ -1316,6 +1316,9 @@ export default { enrichedRatio: '{enriched}/{total} linked', failedJobs: '{count} failed', }, + noPages: 'No pages yet', + noResults: 'No pages match your search', + loadMore: 'Load {n} more', }, cronJobs: { kicker: 'Automation', diff --git a/mateclaw-ui/src/i18n/locales/zh-CN.ts b/mateclaw-ui/src/i18n/locales/zh-CN.ts index 947224b4..0af5889c 100644 --- a/mateclaw-ui/src/i18n/locales/zh-CN.ts +++ b/mateclaw-ui/src/i18n/locales/zh-CN.ts @@ -1326,6 +1326,9 @@ export default { enrichedRatio: '{enriched}/{total} 已链接', failedJobs: '{count} 个失败', }, + noPages: '暂无页面', + noResults: '未找到匹配页面', + loadMore: '加载更多 {n} 条', }, cronJobs: { kicker: '自动执行', diff --git a/mateclaw-ui/src/stores/useWikiStore.ts b/mateclaw-ui/src/stores/useWikiStore.ts index d6697d67..a64926d1 100644 --- a/mateclaw-ui/src/stores/useWikiStore.ts +++ b/mateclaw-ui/src/stores/useWikiStore.ts @@ -30,6 +30,8 @@ export interface WikiRawMaterial { progressPhase: string | null progressTotal: number progressDone: number + // Page count derived from sourceRawIds (injected by listRaw endpoint) + pageCount?: number } export interface WikiPage { @@ -43,6 +45,7 @@ export interface WikiPage { sourceRawIds: string version: number lastUpdatedBy: string + pageType?: string | null createTime: string updateTime: string } diff --git a/mateclaw-ui/src/views/Wiki/components/PageHeader.vue b/mateclaw-ui/src/views/Wiki/components/PageHeader.vue index ba4bf011..ff5e76c1 100644 --- a/mateclaw-ui/src/views/Wiki/components/PageHeader.vue +++ b/mateclaw-ui/src/views/Wiki/components/PageHeader.vue @@ -51,7 +51,7 @@ const props = defineProps<{ version: number lastUpdatedBy: string content?: string | null - pageType?: string + pageType?: string | null sourceRawIds?: string } }>() diff --git a/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue b/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue index e7ed2d1c..d4f38e35 100644 --- a/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue +++ b/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue @@ -65,6 +65,10 @@ {{ t(`wiki.status.${raw.processingStatus}`) }} + + + {{ raw.pageCount }} +
- -
-