From 83eb628513e8a689b5352cae265deb369c7ed819 Mon Sep 17 00:00:00 2001 From: wibus-wee <1596355173@qq.com> Date: Tue, 26 Jul 2022 21:17:57 +0800 Subject: [PATCH] fix(api): return nothing in put or patch method --- src/modules/category/category.controller.ts | 3 ++- src/modules/comment/comment.controller.ts | 4 +--- src/modules/page/page.controller.ts | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/modules/category/category.controller.ts b/src/modules/category/category.controller.ts index b4ab89212..c4b19fb80 100644 --- a/src/modules/category/category.controller.ts +++ b/src/modules/category/category.controller.ts @@ -175,6 +175,7 @@ export class CategoryController { // 合并分类 await this.categoryService.mergeCategory(from, to); } + return { message: "success" }; } @Put("/:id") @@ -200,7 +201,7 @@ export class CategoryController { async patch(@Param() params: MongoIdDto, @Body() body: PartialCategoryModel) { const { id } = params; await this.categoryService.model.updateOne({ _id: id }, body); - return; + return await this.categoryService.model.findById(id); } @Delete("/:id") diff --git a/src/modules/comment/comment.controller.ts b/src/modules/comment/comment.controller.ts index aa55b84f9..f11c09a3e 100644 --- a/src/modules/comment/comment.controller.ts +++ b/src/modules/comment/comment.controller.ts @@ -263,14 +263,12 @@ export class CommentController { } try { - await this.commentService.model.updateOne( + return await this.commentService.model.updateOne( { _id: id, }, updateResult ); - - return; } catch { throw new CannotFindException(); } diff --git a/src/modules/page/page.controller.ts b/src/modules/page/page.controller.ts index a3225b4af..452f81a07 100644 --- a/src/modules/page/page.controller.ts +++ b/src/modules/page/page.controller.ts @@ -106,7 +106,7 @@ export class PageController { // body.text = await this.pluginService.usePlugins('page', 'update', body.text) await this.pageService.updateById(id, body); - return; + return await this.pageService.model.findById(id).lean(); } @Delete("/:id")