@@ -3,21 +3,25 @@ package gat_be.dev.domain.review.controller
33import ApiResponse
44import gat_be.dev.common.status.SuccessStatus
55import gat_be.dev.domain.review.dto.request.CreateReviewRequest
6+ import gat_be.dev.domain.review.dto.request.UpdateReviewRequest
67import gat_be.dev.domain.review.dto.response.ReviewDetailResponse
78import gat_be.dev.domain.review.dto.response.ReviewExistsResponse
89import gat_be.dev.domain.review.dto.response.ReviewListResponse
910import gat_be.dev.domain.review.facade.ReviewCreateFacade
1011import gat_be.dev.domain.review.facade.ReviewDetailGetFacade
1112import gat_be.dev.domain.review.facade.ReviewExistsGetFacade
1213import gat_be.dev.domain.review.facade.ReviewListGetFacade
14+ import gat_be.dev.domain.review.service.ReviewService
1315import io.swagger.v3.oas.annotations.Operation
1416import io.swagger.v3.oas.annotations.media.Content
1517import io.swagger.v3.oas.annotations.media.Schema
1618import io.swagger.v3.oas.annotations.tags.Tag
1719import jakarta.validation.Valid
1820import org.springframework.http.ResponseEntity
1921import org.springframework.security.core.annotation.AuthenticationPrincipal
22+ import org.springframework.web.bind.annotation.DeleteMapping
2023import org.springframework.web.bind.annotation.GetMapping
24+ import org.springframework.web.bind.annotation.PatchMapping
2125import org.springframework.web.bind.annotation.PathVariable
2226import org.springframework.web.bind.annotation.PostMapping
2327import org.springframework.web.bind.annotation.RequestBody
@@ -32,7 +36,8 @@ class ReviewController(
3236 private val reviewCreateFacade : ReviewCreateFacade ,
3337 private val reviewListGetFacade : ReviewListGetFacade ,
3438 private val reviewDetailGetFacade : ReviewDetailGetFacade ,
35- private val reviewExistsGetFacade : ReviewExistsGetFacade
39+ private val reviewExistsGetFacade : ReviewExistsGetFacade ,
40+ private val reviewService : ReviewService
3641) {
3742 @PostMapping(" " )
3843 @Operation(summary = " 새로운 리뷰 작성" )
@@ -84,4 +89,33 @@ class ReviewController(
8489 val reviewExistsResponse = reviewExistsGetFacade.getReviewExists(userId, teamId)
8590 return ApiResponse .success(SuccessStatus .GET_REVIEW_EXISTS_SUCCESS , reviewExistsResponse)
8691 }
92+
93+ @PatchMapping(" /{reviewId}" )
94+ @Operation(summary = " 리뷰 수정" )
95+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 200" , description = " 리뷰 수정 성공" , content = [Content ()])
96+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 400" , description = " 리뷰 수정을 위한 필드가 잘못 되었을 경우" , content = [Content ()])
97+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 403" , description = " 리뷰 수정을 위한 권한이 없을 경우" , content = [Content ()])
98+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 404" , description = " 리뷰가 존재하지 않을 경우" , content = [Content ()])
99+ fun updateReview (
100+ @AuthenticationPrincipal userId : Long ,
101+ @PathVariable reviewId : Long ,
102+ @RequestBody request : UpdateReviewRequest
103+ ): ResponseEntity <ApiResponse <Nothing >> {
104+ reviewService.updateReview(userId, reviewId, request)
105+ return ApiResponse .success(SuccessStatus .UPDATE_REVIEW_SUCCESS )
106+ }
107+
108+ @DeleteMapping(" /{reviewId}" )
109+ @Operation(summary = " 리뷰 삭제" )
110+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 200" , description = " 리뷰 삭제 성공" , content = [Content ()])
111+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 403" , description = " 리뷰 삭제를 위한 권한이 없을 경우" , content = [Content ()])
112+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 404" , description = " 리뷰가 존재하지 않을 경우" , content = [Content ()])
113+ fun deleteReview (
114+ @AuthenticationPrincipal userId : Long ,
115+ @PathVariable reviewId : Long
116+ ): ResponseEntity <ApiResponse <Nothing >> {
117+ reviewService.deleteReview(userId, reviewId)
118+ return ApiResponse .success(SuccessStatus .DELETE_REVIEW_SUCCESS )
119+ }
120+
87121}
0 commit comments