diff --git a/src/main/kotlin/com/restaurant/be/restaurant/presentation/dto/LikeRestaurantDto.kt b/src/main/kotlin/com/restaurant/be/restaurant/presentation/dto/LikeRestaurantDto.kt index 5de1601..68faca5 100644 --- a/src/main/kotlin/com/restaurant/be/restaurant/presentation/dto/LikeRestaurantDto.kt +++ b/src/main/kotlin/com/restaurant/be/restaurant/presentation/dto/LikeRestaurantDto.kt @@ -10,15 +10,10 @@ data class GetLikeRestaurantsResponse( ) data class LikeRestaurantRequest( - @ApiModelProperty(value = "현재 좋아요 했는지 여부", example = "LIKE", required = true) - val status: LikeRestaurantStatus + @ApiModelProperty(value = "현재 좋아요 했는지 여부", example = "false", required = true) + val isLike: Boolean ) data class LikeRestaurantResponse( @Schema(description = "좋아요한 식당 정보") val restaurant: RestaurantDto ) - -enum class LikeRestaurantStatus { - LIKE, - UNLIKE -} diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/controller/CreateReviewController.kt b/src/main/kotlin/com/restaurant/be/review/presentation/controller/CreateReviewController.kt new file mode 100644 index 0000000..b603c1c --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/controller/CreateReviewController.kt @@ -0,0 +1,36 @@ +package com.restaurant.be.review.presentation.controller + +import com.restaurant.be.common.response.CommonResponse +import com.restaurant.be.review.presentation.dto.CreateReviewResponse +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.v3.oas.annotations.media.Content +import io.swagger.v3.oas.annotations.media.Schema +import io.swagger.v3.oas.annotations.responses.ApiResponse +import org.springframework.security.access.prepost.PreAuthorize +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.security.Principal + +@Api(tags = ["03. Review Info"], description = "리뷰 서비스") +@RestController +@RequestMapping("/api/v1/restaurants") +class CreateReviewController { + + @PostMapping("/{restaurantId}/reviews") + @PreAuthorize("hasRole('USER')") + @ApiOperation(value = "리뷰 작성 API") + @ApiResponse( + responseCode = "200", + description = "성공", + content = [Content(schema = Schema(implementation = CreateReviewResponse::class))] + ) + fun createReview( + principal: Principal, + @PathVariable restaurantId: String + ): CommonResponse { + return CommonResponse.success() + } +} diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/controller/DeleteReviewController.kt b/src/main/kotlin/com/restaurant/be/review/presentation/controller/DeleteReviewController.kt new file mode 100644 index 0000000..ec636bc --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/controller/DeleteReviewController.kt @@ -0,0 +1,33 @@ +package com.restaurant.be.review.presentation.controller + +import com.restaurant.be.common.response.CommonResponse +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.v3.oas.annotations.responses.ApiResponse +import org.springframework.security.access.prepost.PreAuthorize +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.security.Principal + +@Api(tags = ["03. Review Info"], description = "리뷰 서비스") +@RestController +@RequestMapping("/api/v1/restaurants/") +class DeleteReviewController { + + @DeleteMapping("/{restaurantId}/reviews/{reviewId}") + @PreAuthorize("hasRole('USER')") + @ApiOperation(value = "리뷰 삭제 API") + @ApiResponse( + responseCode = "200", + description = "성공" + ) + fun deleteReview( + principal: Principal, + @PathVariable restaurantId: String, + @PathVariable reviewId: String + ): CommonResponse { + return CommonResponse.success() + } +} diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/controller/GetMyReviewController.kt b/src/main/kotlin/com/restaurant/be/review/presentation/controller/GetMyReviewController.kt new file mode 100644 index 0000000..752cab7 --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/controller/GetMyReviewController.kt @@ -0,0 +1,34 @@ +package com.restaurant.be.review.presentation.controller + +import com.restaurant.be.common.response.CommonResponse +import com.restaurant.be.review.presentation.dto.GetMyReviewResponse +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.v3.oas.annotations.media.Content +import io.swagger.v3.oas.annotations.media.Schema +import io.swagger.v3.oas.annotations.responses.ApiResponse +import org.springframework.security.access.prepost.PreAuthorize +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.security.Principal + +@Api(tags = ["03. Review Info"], description = "리뷰 서비스") +@RestController +@RequestMapping("/api/v1/restaurants/my-reviews") +class GetMyReviewController { + + @GetMapping + @PreAuthorize("hasRole('USER')") + @ApiOperation(value = "내가 작성한 리뷰 리스트 조회 API") + @ApiResponse( + responseCode = "200", + description = "성공", + content = [Content(schema = Schema(implementation = GetMyReviewResponse::class))] + ) + fun getMyReview( + principal: Principal + ): CommonResponse { + return CommonResponse.success() + } +} diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/controller/GetReviewController.kt b/src/main/kotlin/com/restaurant/be/review/presentation/controller/GetReviewController.kt new file mode 100644 index 0000000..7668ed0 --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/controller/GetReviewController.kt @@ -0,0 +1,34 @@ +package com.restaurant.be.review.presentation.controller + +import com.restaurant.be.common.response.CommonResponse +import com.restaurant.be.review.presentation.dto.GetReviewResponse +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.v3.oas.annotations.media.Content +import io.swagger.v3.oas.annotations.media.Schema +import io.swagger.v3.oas.annotations.responses.ApiResponse +import org.springframework.security.access.prepost.PreAuthorize +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.security.Principal + +@Api(tags = ["03. Review Info"], description = "리뷰 서비스") +@RestController +@RequestMapping("/api/v1/restaurants/reviews") +class GetReviewController { + + @GetMapping + @PreAuthorize("hasRole('USER')") + @ApiOperation(value = "리뷰 리스트 조회 API") + @ApiResponse( + responseCode = "200", + description = "성공", + content = [Content(schema = Schema(implementation = GetReviewResponse::class))] + ) + fun getReview( + principal: Principal + ): CommonResponse { + return CommonResponse.success() + } +} diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/controller/LikeReviewController.kt b/src/main/kotlin/com/restaurant/be/review/presentation/controller/LikeReviewController.kt new file mode 100644 index 0000000..db14843 --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/controller/LikeReviewController.kt @@ -0,0 +1,42 @@ +package com.restaurant.be.review.presentation.controller + +import com.restaurant.be.common.response.CommonResponse +import com.restaurant.be.review.presentation.dto.LikeReviewRequest +import com.restaurant.be.review.presentation.dto.LikeReviewResponse +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.v3.oas.annotations.media.Content +import io.swagger.v3.oas.annotations.media.Schema +import io.swagger.v3.oas.annotations.responses.ApiResponse +import org.springframework.security.access.prepost.PreAuthorize +import org.springframework.web.bind.annotation.PathVariable +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.RestController +import java.security.Principal +import javax.validation.Valid + +@Api(tags = ["03. Review Info"], description = "리뷰 서비스") +@RestController +@RequestMapping("/api/v1/restaurants") +class LikeReviewController { + + @PostMapping("/{restaurantId}/reviews/{reviewId}/like") + @PreAuthorize("hasRole('USER')") + @ApiOperation(value = "리뷰 좋아요 API") + @ApiResponse( + responseCode = "200", + description = "성공", + content = [Content(schema = Schema(implementation = LikeReviewResponse::class))] + ) + fun likeReview( + principal: Principal, + @PathVariable restaurantId: String, + @PathVariable reviewId: String, + @RequestBody @Valid + request: LikeReviewRequest + ): CommonResponse { + return CommonResponse.success() + } +} diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/controller/UpdateReviewController.kt b/src/main/kotlin/com/restaurant/be/review/presentation/controller/UpdateReviewController.kt new file mode 100644 index 0000000..54e3505 --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/controller/UpdateReviewController.kt @@ -0,0 +1,41 @@ +package com.restaurant.be.review.presentation.controller + +import com.restaurant.be.common.response.CommonResponse +import com.restaurant.be.review.presentation.dto.UpdateReviewResponse +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.v3.oas.annotations.media.Content +import io.swagger.v3.oas.annotations.media.Schema +import io.swagger.v3.oas.annotations.responses.ApiResponse +import org.springframework.security.access.prepost.PreAuthorize +import org.springframework.web.bind.annotation.PatchMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController +import java.security.Principal +import javax.validation.Valid + +@Api(tags = ["03. Review Info"], description = "리뷰 서비스") +@RestController +@RequestMapping("/api/v1/restaurants/reviews") +class UpdateReviewController { + + @PatchMapping("/{restaurantId}/reviews/{reviewId}") + @PreAuthorize("hasRole('USER')") + @ApiOperation(value = "리뷰 수정 API") + @ApiResponse( + responseCode = "200", + description = "성공", + content = [Content(schema = Schema(implementation = UpdateReviewResponse::class))] + ) + fun updateReview( + principal: Principal, + @PathVariable restaurantId: String, + @PathVariable reviewId: String, + @RequestBody @Valid + request: UpdateReviewResponse + ): CommonResponse { + return CommonResponse.success() + } +} diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/dto/CreateReviewDto.kt b/src/main/kotlin/com/restaurant/be/review/presentation/dto/CreateReviewDto.kt new file mode 100644 index 0000000..c6755af --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/dto/CreateReviewDto.kt @@ -0,0 +1,15 @@ +package com.restaurant.be.review.presentation.dto + +import com.restaurant.be.review.presentation.dto.common.ReviewRequestDto +import com.restaurant.be.review.presentation.dto.common.ReviewResponseDto +import io.swagger.annotations.ApiModelProperty + +data class CreateReviewRequest( + @ApiModelProperty(value = "리뷰 정보", required = true) + val review: ReviewRequestDto +) + +data class CreateReviewResponse( + @ApiModelProperty(value = "리뷰 정보", required = true) + val review: ReviewResponseDto +) diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/dto/GetMyReviewDto.kt b/src/main/kotlin/com/restaurant/be/review/presentation/dto/GetMyReviewDto.kt new file mode 100644 index 0000000..30dd251 --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/dto/GetMyReviewDto.kt @@ -0,0 +1,11 @@ +@file:Suppress("ktlint", "MatchingDeclarationName") + +package com.restaurant.be.review.presentation.dto + +import com.restaurant.be.review.presentation.dto.common.ReviewResponseDto +import io.swagger.v3.oas.annotations.media.Schema + +data class GetMyReviewResponse( + @Schema(description = "리뷰 리스트") + val reviews: List +) diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/dto/GetReviewDto.kt b/src/main/kotlin/com/restaurant/be/review/presentation/dto/GetReviewDto.kt new file mode 100644 index 0000000..d2cf35c --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/dto/GetReviewDto.kt @@ -0,0 +1,11 @@ +@file:Suppress("ktlint", "MatchingDeclarationName") + +package com.restaurant.be.review.presentation.dto + +import com.restaurant.be.review.presentation.dto.common.ReviewResponseDto +import io.swagger.v3.oas.annotations.media.Schema + +data class GetReviewResponse( + @Schema(description = "리뷰 리스트") + val reviews: List +) diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/dto/LikeReviewDto.kt b/src/main/kotlin/com/restaurant/be/review/presentation/dto/LikeReviewDto.kt new file mode 100644 index 0000000..8c8ffad --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/dto/LikeReviewDto.kt @@ -0,0 +1,15 @@ +package com.restaurant.be.review.presentation.dto + +import com.restaurant.be.review.presentation.dto.common.ReviewResponseDto +import io.swagger.annotations.ApiModelProperty +import io.swagger.v3.oas.annotations.media.Schema + +data class LikeReviewRequest( + @ApiModelProperty(value = "리뷰 좋아요 여부", required = true) + val isLike: Boolean +) + +data class LikeReviewResponse( + @Schema(description = "리뷰 정보") + val review: ReviewResponseDto +) diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/dto/UpdateReviewDto.kt b/src/main/kotlin/com/restaurant/be/review/presentation/dto/UpdateReviewDto.kt new file mode 100644 index 0000000..7571617 --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/dto/UpdateReviewDto.kt @@ -0,0 +1,16 @@ +package com.restaurant.be.review.presentation.dto + +import com.restaurant.be.review.presentation.dto.common.ReviewRequestDto +import com.restaurant.be.review.presentation.dto.common.ReviewResponseDto +import io.swagger.annotations.ApiModelProperty +import io.swagger.v3.oas.annotations.media.Schema + +data class UpdateReviewRequest( + @ApiModelProperty(value = "리뷰 정보", required = true) + val review: ReviewRequestDto +) + +data class UpdateReviewResponse( + @Schema(description = "리뷰 정보") + val review: ReviewResponseDto +) diff --git a/src/main/kotlin/com/restaurant/be/review/presentation/dto/common/ReviewDto.kt b/src/main/kotlin/com/restaurant/be/review/presentation/dto/common/ReviewDto.kt new file mode 100644 index 0000000..41bb448 --- /dev/null +++ b/src/main/kotlin/com/restaurant/be/review/presentation/dto/common/ReviewDto.kt @@ -0,0 +1,35 @@ +package com.restaurant.be.review.presentation.dto.common + +import io.swagger.v3.oas.annotations.media.Schema + +data class ReviewRequestDto( + @Schema(description = "리뷰 id") + val id: Long, + @Schema(description = "유저 id") + val userId: Long, + @Schema(description = "식당 id") + val restaurantId: Long, + @Schema(description = "평가 점수") + val rating: Int, + @Schema(description = "리뷰 내용") + val comment: String, + @Schema(description = "이미지 url 리스트") + val imageUrls: List, + @Schema(description = "좋아요 여부") + val isLike: Boolean +) + +data class ReviewResponseDto( + @Schema(description = "유저 id") + val userId: Long, + @Schema(description = "식당 id") + val restaurantId: Long, + @Schema(description = "평가 점수") + val rating: Int, + @Schema(description = "리뷰 내용") + val comment: String, + @Schema(description = "이미지 url 리스트") + val imageUrls: List, + @Schema(description = "좋아요 여부") + val isLike: Boolean +)