|
| 1 | +import { |
| 2 | + Body, |
| 3 | + Controller, |
| 4 | + Delete, |
| 5 | + HttpCode, |
| 6 | + HttpStatus, |
| 7 | + Patch, |
| 8 | + Post, |
| 9 | + Req, |
| 10 | + UseGuards, |
| 11 | +} from '@nestjs/common'; |
| 12 | +import { ApiTags } from '@nestjs/swagger'; |
| 13 | +import { CommentService } from '../service/comment.service'; |
| 14 | +import { ApiCreateComment } from '../api-docs/createComment.api-docs'; |
| 15 | +import { ApiDeleteComment } from '../api-docs/deleteComment.api-docs'; |
| 16 | +import { ApiUpdateComment } from '../api-docs/updateComment.api-docs'; |
| 17 | +import { JwtGuard } from '../../common/guard/jwt.guard'; |
| 18 | +import { ApiResponse } from '../../common/response/common.response'; |
| 19 | +import { CreateCommentRequestDto } from '../dto/request/create-comment.dto'; |
| 20 | +import { DeleteCommentRequestDto } from '../dto/request/delete-comment.dto'; |
| 21 | +import { UpdateCommentRequestDto } from '../dto/request/update-comment.dto'; |
| 22 | + |
| 23 | +@ApiTags('Comment') |
| 24 | +@Controller('comment') |
| 25 | +@UseGuards(JwtGuard) |
| 26 | +export class CommentController { |
| 27 | + constructor(private readonly commentService: CommentService) {} |
| 28 | + |
| 29 | + @ApiCreateComment() |
| 30 | + @Post() |
| 31 | + @HttpCode(HttpStatus.CREATED) |
| 32 | + async createComment(@Req() req, @Body() commentDto: CreateCommentRequestDto) { |
| 33 | + await this.commentService.create(req.user, commentDto); |
| 34 | + return ApiResponse.responseWithNoContent('댓글 등록을 성공했습니다.'); |
| 35 | + } |
| 36 | + |
| 37 | + @ApiDeleteComment() |
| 38 | + @Delete() |
| 39 | + @HttpCode(HttpStatus.OK) |
| 40 | + async deleteComment(@Req() req, @Body() commentDto: DeleteCommentRequestDto) { |
| 41 | + await this.commentService.delete(req.user, commentDto); |
| 42 | + return ApiResponse.responseWithNoContent('댓글 삭제를 성공했습니다.'); |
| 43 | + } |
| 44 | + |
| 45 | + @ApiUpdateComment() |
| 46 | + @Patch() |
| 47 | + @HttpCode(HttpStatus.OK) |
| 48 | + async updateComment(@Req() req, @Body() commentDto: UpdateCommentRequestDto) { |
| 49 | + await this.commentService.update(req.user, commentDto); |
| 50 | + return ApiResponse.responseWithNoContent('댓글 수정을 성공했습니다.'); |
| 51 | + } |
| 52 | +} |
0 commit comments