feat: enhance textbook reader with anchor text support and improve knowledge point management

This commit is contained in:
SpecialX
2026-01-16 10:22:16 +08:00
parent 9bfc621d3f
commit bb4555f611
44 changed files with 6284 additions and 2090 deletions

View File

@@ -366,29 +366,28 @@ export const getKnowledgePointsByTextbookId = cache(async (textbookId: string):
}))
})
export async function createKnowledgePoint(data: CreateKnowledgePointInput): Promise<KnowledgePoint> {
const id = createId()
const row = {
id,
name: data.name.trim(),
description: normalizeOptional(data.description ?? null),
export async function createKnowledgePoint(data: { name: string; description?: string; anchorText?: string; chapterId?: string; parentId?: string }): Promise<void> {
await db.insert(knowledgePoints).values({
id: createId(),
name: data.name,
description: data.description,
anchorText: data.anchorText,
chapterId: data.chapterId,
level: 1,
order: 0,
}
parentId: data.parentId,
level: 0, // Default level
order: 0, // Default order
})
}
await db.insert(knowledgePoints).values(row)
return {
id: row.id,
name: row.name,
description: row.description,
parentId: null,
chapterId: row.chapterId,
level: row.level,
order: row.order,
}
export async function updateKnowledgePoint(data: { id: string; name: string; description?: string; anchorText?: string }): Promise<void> {
await db
.update(knowledgePoints)
.set({
name: data.name,
description: data.description,
anchorText: data.anchorText,
})
.where(eq(knowledgePoints.id, data.id))
}
export async function deleteKnowledgePoint(id: string): Promise<void> {