diff --git a/src/main/kotlin/org/meogo/domain/comment/exception/CommentNotFoundException.kt b/src/main/kotlin/org/meogo/domain/comment/exception/CommentNotFoundException.kt index d10abd4..f2f2b9f 100644 --- a/src/main/kotlin/org/meogo/domain/comment/exception/CommentNotFoundException.kt +++ b/src/main/kotlin/org/meogo/domain/comment/exception/CommentNotFoundException.kt @@ -3,6 +3,6 @@ package org.meogo.domain.comment.exception import org.meogo.global.error.exception.ErrorCode import org.meogo.global.error.exception.MeogoException -object CommentNotFoundException: MeogoException( +object CommentNotFoundException : MeogoException( ErrorCode.COMMENT_NOT_FOUND -) \ No newline at end of file +) diff --git a/src/main/kotlin/org/meogo/domain/comment/presentation/CommentController.kt b/src/main/kotlin/org/meogo/domain/comment/presentation/CommentController.kt index f4ae96c..be44918 100644 --- a/src/main/kotlin/org/meogo/domain/comment/presentation/CommentController.kt +++ b/src/main/kotlin/org/meogo/domain/comment/presentation/CommentController.kt @@ -3,16 +3,16 @@ package org.meogo.domain.comment.presentation import lombok.RequiredArgsConstructor import org.meogo.domain.comment.presentation.dto.request.CommentRequest import org.meogo.domain.comment.service.CreateCommentService +import org.meogo.domain.comment.service.DeleteCommentService import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.DeleteMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.bind.annotation.RestController import javax.validation.Valid -import org.meogo.domain.comment.service.DeleteCommentService -import org.springframework.web.bind.annotation.DeleteMapping -import org.springframework.web.bind.annotation.RequestParam @RequiredArgsConstructor @RestController diff --git a/src/main/kotlin/org/meogo/domain/comment/service/DeleteCommentService.kt b/src/main/kotlin/org/meogo/domain/comment/service/DeleteCommentService.kt index 0b4c6b2..f43a1a3 100644 --- a/src/main/kotlin/org/meogo/domain/comment/service/DeleteCommentService.kt +++ b/src/main/kotlin/org/meogo/domain/comment/service/DeleteCommentService.kt @@ -15,11 +15,12 @@ class DeleteCommentService( @Transactional fun execute(commentId: Long) { val user = userFacade.currentUser()!! - val comment = commentRepository.findById(commentId)?: throw CommentNotFoundException + val comment = commentRepository.findById(commentId) ?: throw CommentNotFoundException - if(user.id != comment.user.id) + if (user.id != comment.user.id) { throw UserMisMatchException + } commentRepository.deleteById(comment.id) } -} \ No newline at end of file +}