11package gat_be.dev.domain.review.controller
22
3- import gat_be.dev.domain.review.service.ReviewService
3+ import ApiResponse
4+ import gat_be.dev.common.status.SuccessStatus
5+ import gat_be.dev.domain.review.dto.request.CreateReviewRequest
6+ import gat_be.dev.domain.review.dto.response.ReviewDetailResponse
7+ import gat_be.dev.domain.review.dto.response.ReviewExistsResponse
8+ import gat_be.dev.domain.review.dto.response.ReviewListResponse
9+ import gat_be.dev.domain.review.facade.ReviewCreateFacade
10+ import gat_be.dev.domain.review.facade.ReviewDetailGetFacade
11+ import gat_be.dev.domain.review.facade.ReviewExistsGetFacade
12+ import gat_be.dev.domain.review.facade.ReviewListGetFacade
13+ import io.swagger.v3.oas.annotations.Operation
14+ import io.swagger.v3.oas.annotations.media.Content
15+ import io.swagger.v3.oas.annotations.media.Schema
16+ import io.swagger.v3.oas.annotations.tags.Tag
17+ import jakarta.validation.Valid
18+ import org.springframework.http.ResponseEntity
19+ import org.springframework.security.core.annotation.AuthenticationPrincipal
20+ import org.springframework.web.bind.annotation.GetMapping
21+ import org.springframework.web.bind.annotation.PathVariable
22+ import org.springframework.web.bind.annotation.PostMapping
23+ import org.springframework.web.bind.annotation.RequestBody
424import org.springframework.web.bind.annotation.RequestMapping
25+ import org.springframework.web.bind.annotation.RequestParam
526import org.springframework.web.bind.annotation.RestController
627
728@RestController
8- @RequestMapping() // TODO:
29+ @RequestMapping(" /reviews" )
30+ @Tag(name = " Review" )
931class ReviewController (
10- private val reviewService : ReviewService
32+ private val reviewCreateFacade : ReviewCreateFacade ,
33+ private val reviewListGetFacade : ReviewListGetFacade ,
34+ private val reviewDetailGetFacade : ReviewDetailGetFacade ,
35+ private val reviewExistsGetFacade : ReviewExistsGetFacade
1136) {
37+ @PostMapping(" " )
38+ @Operation(summary = " 새로운 리뷰 작성" )
39+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 200" , description = " 리뷰 작성 성공" , content = [Content ()])
40+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 400" , description = " 리뷰 작성에 필요한 값들이 유효하지 않은 경우" , content = [Content ()])
41+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 403" , description = " 해당 유저와 같은 팀이 아닌 경우" , content = [Content ()])
42+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 409" , description = " 팀 활동이 종료되기 전 리뷰를 작성하거나 유저 스스로에게 리뷰를 쓰는 경우" , content = [Content ()])
43+ fun createReview (
44+ @AuthenticationPrincipal userId : Long ,
45+ @Valid @RequestBody request : CreateReviewRequest
46+ ): ResponseEntity <ApiResponse <Nothing >> {
47+ reviewCreateFacade.createReview(userId, request)
48+ return ApiResponse .success(SuccessStatus .CREATE_REVIEW_SUCCESS )
49+ }
1250
51+ @GetMapping(" /list/{userId}" )
52+ @Operation(summary = " 리뷰 리스트 조회" )
53+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 200" , description = " 리뷰 리스트 조회 성공" , content = [Content (mediaType = " application/json" , schema = Schema (implementation = ReviewListResponse ::class ))])
54+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 400" , description = " 리뷰 리스트 조회 파라미터가 올바르지 않은 경우" , content = [Content ()])
55+ fun getReviewList (
56+ @PathVariable userId : Long ,
57+ @RequestParam(required = false , defaultValue = " createdAt" ) sort : String ,
58+ @RequestParam(required = false , defaultValue = " asc" ) order : String
59+ ): ResponseEntity <ApiResponse <ReviewListResponse >> {
60+ val reviewListResponse = reviewListGetFacade.getReviewList(userId, sort, order)
61+ return ApiResponse .success(SuccessStatus .GET_REVIEW_LIST_SUCCESS , reviewListResponse)
62+ }
63+
64+ @GetMapping(" /{reviewId}" )
65+ @Operation(summary = " 리뷰 상세 조회" )
66+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 200" , description = " 리뷰 상세 조회 성공" , content = [Content (mediaType = " application/json" , schema = Schema (implementation = ReviewDetailResponse ::class ))])
67+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 404" , description = " 해당 리뷰 혹은 팀원 정보를 찾을 수 없는 경우" , content = [Content ()])
68+ fun getReviewDetail (
69+ @AuthenticationPrincipal userId : Long ,
70+ @PathVariable reviewId : Long
71+ ): ResponseEntity <ApiResponse <ReviewDetailResponse >> {
72+ val reviewDetailResponse = reviewDetailGetFacade.getReviewDetail(reviewId)
73+ return ApiResponse .success(SuccessStatus .GET_REVIEW_DETAIL_SUCCESS , reviewDetailResponse)
74+ }
75+
76+ @GetMapping(" /{teamId}/exists" )
77+ @Operation(summary = " 리뷰 작성 여부 조회" )
78+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 200" , description = " 리뷰 작성 여부 조회 성공" , content = [Content (mediaType = " application/json" , schema = Schema (implementation = ReviewExistsResponse ::class ))])
79+ @io.swagger.v3.oas.annotations.responses.ApiResponse (responseCode = " 403" , description = " 팀에 대한 접근 권한이 없는 경우" , content = [Content ()])
80+ fun getReviewExists (
81+ @AuthenticationPrincipal userId : Long ,
82+ @PathVariable teamId : Long
83+ ): ResponseEntity <ApiResponse <ReviewExistsResponse >> {
84+ val reviewExistsResponse = reviewExistsGetFacade.getReviewExists(userId, teamId)
85+ return ApiResponse .success(SuccessStatus .GET_REVIEW_EXISTS_SUCCESS , reviewExistsResponse)
86+ }
1387}
0 commit comments