import { Injectable, NotFoundException } from '@nestjs/common'; import { KnowledgeItemsRepository } from './knowledge-items.repository'; @Injectable() export class KnowledgeItemsService { constructor(private readonly repository: KnowledgeItemsRepository) {} async create(userId: string, knowledgeBaseId: string, dto: any) { return this.repository.create(userId, knowledgeBaseId, dto); } async findById(id: string) { const item = await this.repository.findById(id); if (!item) throw new NotFoundException('知识点不存在'); return item; } async findByKnowledgeBaseId(knowledgeBaseId: string) { return this.repository.findByKnowledgeBaseId(knowledgeBaseId); } async update(id: string, dto: any) { const item = await this.repository.update(id, dto); if (!item) throw new NotFoundException('知识点不存在'); return item; } }