@@ -11,6 +11,7 @@ import {
11
11
} from 'src/common/exception/service.exception' ;
12
12
import { UserService } from 'src/user/user.service' ;
13
13
import { PostService } from 'src/post/post.service' ;
14
+ import { StatusEnum } from 'src/common/enum/entityStatus' ;
14
15
15
16
@Injectable ( )
16
17
export class PostCommentService {
@@ -29,10 +30,10 @@ export class PostCommentService {
29
30
createCommentDto : CreateCommentDto ,
30
31
) : Promise < PostComment > {
31
32
const post = await this . postService . findByFields ( {
32
- where : { id : postId , status : 'activated' } ,
33
+ where : { id : postId , status : StatusEnum . ACTIVATED } ,
33
34
} ) ;
34
35
const user = await this . userService . findByFields ( {
35
- where : { id : currentUserId , status : 'activated' } ,
36
+ where : { id : currentUserId , status : StatusEnum . ACTIVATED } ,
36
37
} ) ;
37
38
const postComment = this . postCommentRepository . create ( {
38
39
content : createCommentDto . content ,
@@ -54,7 +55,7 @@ export class PostCommentService {
54
55
55
56
await Promise . all (
56
57
commentsToRemove . map ( async ( comment ) => {
57
- comment . status = 'deactivated' ;
58
+ comment . status = StatusEnum . DEACTIVATED ;
58
59
comment . softDelete ( ) ;
59
60
return queryRunner . manager . save ( comment ) ;
60
61
} ) ,
@@ -70,7 +71,7 @@ export class PostCommentService {
70
71
const comment = await this . findCommentById ( commentId ) ;
71
72
72
73
try {
73
- comment . status = 'deactivated' ;
74
+ comment . status = StatusEnum . DEACTIVATED ;
74
75
comment . softDelete ( ) ;
75
76
76
77
await queryRunner . manager . save ( comment ) ;
@@ -92,8 +93,8 @@ export class PostCommentService {
92
93
return await this . postCommentRepository . find ( {
93
94
where : {
94
95
post : { id : postId } ,
95
- status : 'activated' ,
96
- user : { status : 'activated' , id : Not ( In ( blockedUserIds ) ) } ,
96
+ status : StatusEnum . ACTIVATED ,
97
+ user : { status : StatusEnum . ACTIVATED , id : Not ( In ( blockedUserIds ) ) } ,
97
98
} ,
98
99
relations : [ 'user' ] ,
99
100
} ) ;
@@ -103,8 +104,8 @@ export class PostCommentService {
103
104
const comment = await this . postCommentRepository . findOne ( {
104
105
where : {
105
106
id : commentId ,
106
- status : 'activated' ,
107
- user : { status : 'activated' } ,
107
+ status : StatusEnum . ACTIVATED ,
108
+ user : { status : StatusEnum . ACTIVATED } ,
108
109
} ,
109
110
relations : [ 'user' ] ,
110
111
} ) ;
0 commit comments