Skip to content

Commit 4945373

Browse files
committed
feat: 댓글 생성 기능
1 parent 3420f60 commit 4945373

File tree

2 files changed

+3
-39
lines changed

2 files changed

+3
-39
lines changed

src/post-comment/dtos/create-comment.dto.ts

-26
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,3 @@ export class CreateCommentDto {
1010
@MaxLength(100)
1111
content: string;
1212
}
13-
14-
export class CreateCommentResponseDto {
15-
@ApiProperty({
16-
example: '댓글 내용',
17-
description: '작성된 댓글 내용',
18-
})
19-
content: string;
20-
21-
@ApiProperty({
22-
example: 1,
23-
description: '작성자 ID',
24-
})
25-
userId: number;
26-
27-
@ApiProperty({
28-
example: 19,
29-
description: '게시글 ID',
30-
})
31-
postId: number;
32-
33-
@ApiProperty({
34-
example: '2024-10-28T11:24:35.000Z',
35-
description: '댓글 작성 시간',
36-
})
37-
createdAt: Date;
38-
}

src/post-comment/post-comment.controller.ts

+3-13
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ import {
1515
GetPostCommentsSwagger,
1616
} from './post-comment.swagger';
1717
import { ApiTags } from '@nestjs/swagger';
18-
import {
19-
CreateCommentDto,
20-
CreateCommentResponseDto,
21-
} from './dtos/create-comment.dto';
18+
import { CreateCommentDto } from './dtos/create-comment.dto';
2219
import { Request } from 'express';
2320
import { BaseResponse } from 'src/common/response/dto';
2421
import { PostService } from 'src/post/post.service';
@@ -39,7 +36,7 @@ export class PostCommentController {
3936
@Query('postId') postId: number,
4037
@Body() createCommentDto: CreateCommentDto,
4138
@Req() req: Request,
42-
): Promise<BaseResponse<CreateCommentResponseDto>> {
39+
): Promise<BaseResponse<any>> {
4340
const currentUserId = req.user.userId;
4441

4542
await this.postService.validatePost(postId);
@@ -50,14 +47,7 @@ export class PostCommentController {
5047
createCommentDto,
5148
);
5249

53-
const responseData: CreateCommentResponseDto = {
54-
content: postComment.content,
55-
userId: currentUserId,
56-
postId: postId,
57-
createdAt: postComment.createdAt,
58-
};
59-
60-
return new BaseResponse(true, '댓글 작성 성공', responseData);
50+
return new BaseResponse(true, '댓글 작성 성공', postComment);
6151
}
6252

6353
@Get()

0 commit comments

Comments
 (0)