feat: enhance textbook reader with anchor text support and improve knowledge point management
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user