diff --git a/packages/server/src/services/document.service.ts b/packages/server/src/services/document.service.ts index 108cc39..dec2c17 100644 --- a/packages/server/src/services/document.service.ts +++ b/packages/server/src/services/document.service.ts @@ -358,7 +358,10 @@ export class DocumentService { async deleteDocument(user: OutUser, documentId) { const document = await this.documentRepo.findOne(documentId); if (document.isWikiHome) { - throw new HttpException('该文档作为知识库首页使用,无法删除', HttpStatus.FORBIDDEN); + const isWikiExist = await this.wikiService.findById(document.wikiId); + if (isWikiExist) { + throw new HttpException('该文档作为知识库首页使用,无法删除', HttpStatus.FORBIDDEN); + } } const children = await this.documentRepo.find({ parentDocumentId: document.id, diff --git a/packages/server/src/services/wiki.service.ts b/packages/server/src/services/wiki.service.ts index 04a89f9..74ed373 100644 --- a/packages/server/src/services/wiki.service.ts +++ b/packages/server/src/services/wiki.service.ts @@ -458,9 +458,10 @@ export class WikiService { if (user.id !== wiki.createUserId) { throw new HttpException('您不是创建者,无法删除该知识库', HttpStatus.FORBIDDEN); } + await this.wikiRepo.remove(wiki); await this.documentService.deleteWikiDocuments(user, wikiId); const users = await this.wikiUserRepo.find({ wikiId }); - await Promise.all([this.wikiRepo.remove(wiki), this.wikiUserRepo.remove(users)]); + await Promise.all([this.wikiUserRepo.remove(users)]); return wiki; }