Skip to content

Commit

Permalink
fix(page-service): missing page delete api (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
wibus-wee authored Jun 9, 2023
1 parent 113c714 commit a913cfd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/page-service/src/page-service.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,16 @@ export class PageServiceController {

@MessagePattern({ cmd: PageEvents.PagePatch })
@ApiOperation({ summary: '更新页面' })
async patch(input: { params: MongoIdDto; body: PartialPageModel }) {
async patchPage(input: { params: MongoIdDto; body: PartialPageModel }) {
return await this.pageService.updateById(input.params.id, input.body);
}

@MessagePattern({ cmd: PageEvents.PageDelete })
@ApiOperation({ summary: '删除页面' })
async deletePage(id: string) {
return await this.pageService.deletePageById(id);
}

// ==================== Post ====================

@MessagePattern({ cmd: PostEvents.PostsListGet })
Expand Down
14 changes: 14 additions & 0 deletions apps/page-service/src/page-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,18 @@ export class PageService {
this.notification.emit(NotificationEvents.SystemPageUpdate, res);
return res;
}

/**
* 根据id删除页面
* @param id 页面id
* @returns void
**/
async deletePageById(id: string) {
return this.pageModel.findByIdAndDelete(id).then((res) => {
if (res) {
this.notification.emit(NotificationEvents.SystemPageDelete, res);
}
return true;
});
}
}

0 comments on commit a913cfd

Please sign in to comment.