Commit b732e19 1 parent 3b1d76f commit b732e19 Copy full SHA for b732e19
File tree 2 files changed +19
-5
lines changed
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,10 @@ export class PostCommentController {
61
61
) : Promise < BaseResponse < GetCommentsDto > > {
62
62
const currentUserId = req . user . id ;
63
63
64
- const comments = await this . postCommentService . getPostComments ( postId ) ;
64
+ const comments = await this . postCommentService . getPostComments (
65
+ postId ,
66
+ currentUserId ,
67
+ ) ;
65
68
66
69
const commenteResponse : GetCommentsDto = {
67
70
comments : comments . map ( ( comment ) => ( {
Original file line number Diff line number Diff line change 1
1
import { forwardRef , Inject , Injectable } from '@nestjs/common' ;
2
2
import { PostComment } from 'src/common/entities/post-comment.entity' ;
3
- import { QueryRunner } from 'typeorm' ;
3
+ import { Not , QueryRunner } from 'typeorm' ;
4
4
import { InjectRepository } from '@nestjs/typeorm' ;
5
5
import { Repository } from 'typeorm' ;
6
6
import { CreateCommentDto } from './dtos/create-comment.dto' ;
@@ -85,16 +85,27 @@ export class PostCommentService {
85
85
}
86
86
87
87
// 댓글 리스트 조회
88
- async getPostComments ( postId : number ) : Promise < PostComment [ ] > {
88
+ async getPostComments (
89
+ postId : number ,
90
+ currentUserId : number ,
91
+ ) : Promise < PostComment [ ] > {
89
92
return await this . postCommentRepository . find ( {
90
- where : { post : { id : postId } , status : 'activated' } ,
93
+ where : {
94
+ post : { id : postId } ,
95
+ status : 'activated' ,
96
+ user : { status : 'activated' , id : Not ( currentUserId ) } ,
97
+ } ,
91
98
relations : [ 'user' ] ,
92
99
} ) ;
93
100
}
94
101
95
102
private async findCommentById ( commentId : number ) : Promise < PostComment > {
96
103
const comment = await this . postCommentRepository . findOne ( {
97
- where : { id : commentId , status : 'activated' } ,
104
+ where : {
105
+ id : commentId ,
106
+ status : 'activated' ,
107
+ user : { status : 'activated' } ,
108
+ } ,
98
109
relations : [ 'user' ] ,
99
110
} ) ;
100
111
You can’t perform that action at this time.
0 commit comments