diff --git a/backend/src/modules/post/post.controller.ts b/backend/src/modules/post/post.controller.ts index 8559143..e33c5ed 100644 --- a/backend/src/modules/post/post.controller.ts +++ b/backend/src/modules/post/post.controller.ts @@ -63,4 +63,10 @@ export class PostController { async deletePostByOrder(@Param('order') order: number) { return await this.postService.deletePostByOrder(order); } + + @ApiOperation({ description: 'Get deleted posts' }) + @Get('get-deleted') + async getDeletedPosts() { + return await this.postService.getDeletedPosts(); + } } diff --git a/backend/src/modules/post/post.service.ts b/backend/src/modules/post/post.service.ts index d59a4a7..ed60b57 100644 --- a/backend/src/modules/post/post.service.ts +++ b/backend/src/modules/post/post.service.ts @@ -190,4 +190,13 @@ export class PostService { throw new HttpException('Bad data', HttpStatus.BAD_REQUEST); } } + + async getDeletedPosts() { + try { + return await this.postRepository.find({ where: { deleted: true, posted: false }, order: { timestamp: 'ASC' } }); + } catch (error) { + this.logger.debug(`[post.getDeleted] error: ${JSON.stringify(error)}`); + throw new HttpException('Bad data', HttpStatus.BAD_REQUEST); + } + } }