Skip to content

Commit

Permalink
Merge pull request #52 from FC-InnerCircle/refactor/review
Browse files Browse the repository at this point in the history
Refactor/review
  • Loading branch information
devchanki authored Oct 12, 2024
2 parents fae3290 + 7f9e6d7 commit c27d67c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 32 deletions.
7 changes: 4 additions & 3 deletions scripts/after-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ REPOSITORY=/home/ec2-user

cd $REPOSITORY/o2o-backend

#echo "> 🔵 Stop & Remove docker services."
#cd ..
#docker compose down
echo "> 🔵 Remove docker services."
docker system prune --all -f



echo "> 🟢 Run new docker services."
sudo docker load -i o2o-backend.tar.gz
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package org.inner.circle.o2oserver.store.application

import org.inner.circle.o2oserver.store.domain.review.ReviewInfo
import org.inner.circle.o2oserver.store.domain.review.ReviewQueryObject
import org.inner.circle.o2oserver.store.domain.review.ReviewService
import org.springframework.data.domain.Pageable
import org.springframework.stereotype.Service

@Service
class ReviewFacade(
private val reviewService: ReviewService,
) {
fun getStoreReviewList(queryObject: ReviewQueryObject): List<ReviewInfo> {
return reviewService.getStoreReviewList(queryObject)
fun getStoreReviewList(storeId: Long, pageable: Pageable): List<ReviewInfo> {
return reviewService.getStoreReviewList(storeId, pageable)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.inner.circle.o2oserver.store.domain.review

import org.springframework.data.domain.Pageable

interface ReviewReader {
fun getStoreReviewList(queryObject: ReviewQueryObject): List<Review>
fun getStoreReviewList(storeId: Long, pageable: Pageable): List<Review>
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.inner.circle.o2oserver.store.domain.review

import org.springframework.data.domain.Pageable

interface ReviewService {
fun getStoreReviewList(queryObject: ReviewQueryObject): List<ReviewInfo>
fun getStoreReviewList(storeId: Long, pageable: Pageable): List<ReviewInfo>
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.inner.circle.o2oserver.store.domain.review

import org.springframework.data.domain.Pageable
import org.springframework.stereotype.Service

@Service
class ReviewServiceImpl(private val reviewReader: ReviewReader) : ReviewService {
override fun getStoreReviewList(queryObject: ReviewQueryObject): List<ReviewInfo> {
val reviews = reviewReader.getStoreReviewList(queryObject)
override fun getStoreReviewList(storeId: Long, pageable: Pageable): List<ReviewInfo> {
val reviews = reviewReader.getStoreReviewList(storeId, pageable)
return reviews.map { ReviewInfo(it) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.springframework.stereotype.Component

@Component
class ReviewApiClient {
fun getStoreReviewList(storeId: Int, page: Int, size: Int): ReviewResponseDto {
fun getStoreReviewList(storeId: Long, page: Int, size: Int): ReviewResponseDto {
val reviews =
listOf(
ReviewListResponseDto(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.inner.circle.o2oserver.store.infrastructure.client

import org.inner.circle.o2oserver.store.domain.review.Review
import org.inner.circle.o2oserver.store.domain.review.ReviewQueryObject
import org.inner.circle.o2oserver.store.domain.review.ReviewReader
import org.springframework.data.domain.Pageable
import org.springframework.stereotype.Component

@Component
class ReviewReaderImpl(private val reviewApiClient: ReviewApiClient) : ReviewReader {
override fun getStoreReviewList(queryObject: ReviewQueryObject): List<Review> {
val response = reviewApiClient.getStoreReviewList(queryObject.storeId, queryObject.page, queryObject.limit)
override fun getStoreReviewList(storeId: Long, pageable: Pageable): List<Review> {
val response = reviewApiClient.getStoreReviewList(storeId, pageable.pageNumber, pageable.pageSize)
return response.reviews.map { it.toDomain() }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package org.inner.circle.o2oserver.store.presentation.api
import jakarta.validation.Valid
import org.inner.circle.o2oserver.store.application.ReviewFacade
import org.inner.circle.o2oserver.store.application.StoreFacade
import org.inner.circle.o2oserver.store.domain.review.ReviewQueryObject
import org.inner.circle.o2oserver.store.presentation.dto.CommonListResponse
import org.inner.circle.o2oserver.store.presentation.dto.CommonResponse
import org.inner.circle.o2oserver.store.presentation.dto.StoreListRequest
import org.inner.circle.o2oserver.store.presentation.dto.StoreReviewDTO
import org.springframework.data.domain.Pageable
import org.springframework.data.web.PageableDefault
import org.springframework.validation.BindingResult
import org.springframework.web.bind.annotation.GetMapping
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.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
Expand All @@ -25,7 +25,7 @@ class StoreController(
) {
@GetMapping("/{storeId}")
fun getStoreDetail(
@PathVariable storeId: Long,
@PathVariable @Valid storeId: Long,
): CommonResponse {
val store = storeFacade.getStoreDetail(storeId)
return CommonResponse(response = store, msg = "조회 되었습니다", statusCode = 200)
Expand Down Expand Up @@ -53,27 +53,19 @@ class StoreController(

@GetMapping("/{storeId}/reviews")
fun getStoreDetail(
@PathVariable("storeId") storeId: Int,
@RequestParam("page") page: Int,
@RequestParam("limit") size: Int?,
@PathVariable("storeId") storeId: Long,
@PageableDefault(size = 10, page = 0) pageable: Pageable,
): CommonListResponse {
val queryObject =
ReviewQueryObject(
storeId = storeId,
page = page,
limit = size ?: 10,
)

val reviews = reviewFacade.getStoreReviewList(queryObject)
val reviews = reviewFacade.getStoreReviewList(storeId, pageable)
return CommonListResponse(
response =
StoreReviewDTO(
reviews = reviews,
storeName = "임시 가게 이름",
),
totalCount = 100,
size = size ?: 10,
page = page,
size = pageable.pageSize,
page = pageable.pageNumber,
statusCode = 200,
msg = "목록을 조회했습니다.",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ data class CommonListResponse(
)

data class StoreListRequest(
@field:Positive(message = "위경도 값을 다시 확인해주세요") @Max(value = 38, message = "위경도 값을 다시 확인해주세요")
@field:Positive(message = "위도 값을 다시 확인해주세요") @Max(value = 39, message = "위도 값을 다시 확인해주세요")
val latitude: Double,
@field:Positive(message = "위경도 값을 다시 확인해주세요") @Max(value = 129, message = "위경도 값을 다시 확인해주세요")
@field:Positive(message = "경도 값을 다시 확인해주세요") @Max(value = 129, message = "경도 값을 다시 확인해주세요")
val longitude: Double,
val category: String?,
val page: Int = 0,
Expand Down

0 comments on commit c27d67c

Please sign in to comment.