mirror of https://github.com/fantasticit/think.git
server: fix delete wiki
parent
995be31a41
commit
e804dea750
|
@ -358,8 +358,11 @@ export class DocumentService {
|
|||
async deleteDocument(user: OutUser, documentId) {
|
||||
const document = await this.documentRepo.findOne(documentId);
|
||||
if (document.isWikiHome) {
|
||||
const isWikiExist = await this.wikiService.findById(document.wikiId);
|
||||
if (isWikiExist) {
|
||||
throw new HttpException('该文档作为知识库首页使用,无法删除', HttpStatus.FORBIDDEN);
|
||||
}
|
||||
}
|
||||
const children = await this.documentRepo.find({
|
||||
parentDocumentId: document.id,
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue