Get deleted posts

This commit is contained in:
2024-02-15 11:52:56 +03:00
parent ffb3eb6689
commit 0a4732f731
2 changed files with 15 additions and 0 deletions

View File

@@ -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();
}
}

View File

@@ -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);
}
}
}