Skip to content

Commit

Permalink
v0.1.8-Release (#82)
Browse files Browse the repository at this point in the history
* [etc] logger 추가 및 Exception logging 추가 (#71)

* [etc] CODEOWNERS 수정 (#72)

* Spring boot version 3.1.2 -> 3.1.6 (#73)

* [refactor]cursor 기반 page 타입 변경 (#74)

* [refactor] Swagger UI 라이브러리 변경: Spring REST docs -> Springdoc (#75)

* Swagger UI 라이브러리 변경 - Spring REST docs -> Springdoc

* 컨트롤러 인터페이스 분리

* Update src/main/resources/static/swagger-ui/openapi3.yaml

Co-authored-by: 유도진 <[email protected]>

* build.gradle 의존성 제거

* 인터페이스 이름 변경: ApiPresentation 추가

* 커버리지 체크 제외할 리스트 수정

* postfix 수정

* postfix 수정

* postfix 수정

* postfix 수정

* postfix수정

* REST doc 관련 의존성 및 파일 삭제

* 변경 사항 반영

* 리뷰 반영해서 수정

* 초깃값 동작 체크

---------

Co-authored-by: 유도진 <[email protected]>

* [etc] version 수정 (#77)

* [etc] storeId → cursor 수정 (#79)

* [etc] version 수정 (#80)

---------

Co-authored-by: 유도진 <[email protected]>
Co-authored-by: YOON <[email protected]>
Co-authored-by: Gopistol <[email protected]>
  • Loading branch information
4 people authored Jan 4, 2024
1 parent 75571fb commit f953696
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Application version ###
applicationVersion=0.1.7-RELEASE
applicationVersion=0.1.8-RELEASE

### Project configs ###
projectGroup="com.mjucow"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ class SwaggerConfig {
Info()
.title("Eatda API Documentation")
.description("Eatda(잇다) 서비스의 API 명세서입니다.")
.version("0.1.7")
.version("0.1.8")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ class StoreQueryService(
val repository: StoreRepository,
val popularStoreCommandService: PopularStoreCommandService,
) {
fun findAllByCategoryAndCursor(id: Long? = null, categoryId: Long? = null, size: Int): List<StoreDto> {
fun findAllByCategoryAndCursor(cursor: Long? = null, categoryId: Long? = null, size: Int): List<StoreDto> {
return if (categoryId == null) {
repository.findAllByIdLessThanOrderByIdDesc(size, id).map(StoreDto::from)
repository.findAllByIdLessThanOrderByIdDesc(
size = size,
id = cursor
).map(StoreDto::from)
} else {
// FIXME(cache): store 캐시 처리 이후 store 조회 개선하기
val storeIds = repository.findIdsByCategoryIdOrderByIdDesc(categoryId, size, id)
val storeIds = repository.findIdsByCategoryIdOrderByIdDesc(
categoryId = categoryId,
size = size,
id = cursor
)
repository.findAllByIdInOrderByIdDesc(storeIds).map(StoreDto::from)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface StoreApiPresentation {
@Operation(summary = "커서 기반 카테고리 가게 조회", description = "커서를 기반으로 가게를 조회합니다.")
@StoreDtosApiResponse
fun findAllByCategoryIdAndCursor(
storeId: Long?,
cursor: Long?,
categoryId: Long?,
pageSize: Int,
): ApiResponse<CursorPage<StoreDto>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class StoreController(
@GetMapping
@ResponseStatus(HttpStatus.OK)
override fun findAllByCategoryIdAndCursor(
@RequestParam("storeId", required = false) storeId: Long?,
@RequestParam("cursor", required = false) cursor: Long?,
@RequestParam("categoryId", required = false) categoryId: Long?,
@RequestParam("pageSize", required = false, defaultValue = "20") pageSize: Int,
): ApiResponse<CursorPage<StoreDto>> {
val results = storeQueryService.findAllByCategoryAndCursor(storeId, categoryId, pageSize)
val results = storeQueryService.findAllByCategoryAndCursor(cursor, categoryId, pageSize)

val contents = results.subList(0, min(pageSize, results.size))
val hasNext = results.size > pageSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ class StoreQueryServiceDataTest : AbstractDataTest() {
// given
val pageSize = 2
val latestId = IntStream.range(0, pageSize * 2).mapToLong {
repository.save(Store(name = "validName$it", address = StoreMother.ADDRESS)).id
repository.save(
Store(
name = "validName$it",
address = StoreMother.ADDRESS
)
).id
}.max().asLong

// when
Expand All @@ -84,11 +89,19 @@ class StoreQueryServiceDataTest : AbstractDataTest() {
// given
val pageSize = Store.MAX_NAME_LENGTH - 1
repeat(Store.MAX_NAME_LENGTH) {
repository.save(Store(name = "x".repeat(it + 1), address = StoreMother.ADDRESS))
repository.save(
Store(
name = "x".repeat(it + 1),
address = StoreMother.ADDRESS
)
)
}

// when
val result = storeQueryService.findAllByCategoryAndCursor(id = (pageSize * 2).toLong(), size = pageSize)
val result = storeQueryService.findAllByCategoryAndCursor(
cursor = (pageSize * 2).toLong(),
size = pageSize
)

// then
assertThat(result.size).isEqualTo(pageSize + 1)
Expand All @@ -103,7 +116,10 @@ class StoreQueryServiceDataTest : AbstractDataTest() {
val pageSize = 10

// when
val result = storeQueryService.findAllByCategoryAndCursor(id = storeId + 1, size = pageSize)
val result = storeQueryService.findAllByCategoryAndCursor(
cursor = storeId + 1,
size = pageSize
)

// then
assertThat(result.size).isLessThan(pageSize)
Expand All @@ -118,7 +134,10 @@ class StoreQueryServiceDataTest : AbstractDataTest() {
repository.save(store)

// when
val result = storeQueryService.findAllByCategoryAndCursor(id = store.id, size = pageSize)
val result = storeQueryService.findAllByCategoryAndCursor(
cursor = store.id,
size = pageSize
)

// then
assertThat(result).isEmpty()
Expand All @@ -137,7 +156,10 @@ class StoreQueryServiceDataTest : AbstractDataTest() {
}.max().asLong

// when
val result = storeQueryService.findAllByCategoryAndCursor(categoryId = category.id, size = pageSize)
val result = storeQueryService.findAllByCategoryAndCursor(
categoryId = category.id,
size = pageSize
)

// then
assertThat(result).anyMatch { it.id == latestId }
Expand Down Expand Up @@ -178,7 +200,7 @@ class StoreQueryServiceDataTest : AbstractDataTest() {
// when
val result = storeQueryService.findAllByCategoryAndCursor(
categoryId = category.id,
id = storeId + 1,
cursor = storeId + 1,
size = pageSize
)

Expand All @@ -198,7 +220,7 @@ class StoreQueryServiceDataTest : AbstractDataTest() {
// when
val result = storeQueryService.findAllByCategoryAndCursor(
categoryId = category.id,
id = store.id,
cursor = store.id,
size = 10
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class StoreControllerMvcTest : AbstractMockMvcTest() {
// given
val entityId = 1L
every { storeCommandService.create(any()) } returns entityId
val command = StoreCreateCommand(name = StoreMother.NAME, address = StoreMother.ADDRESS)
val command = StoreCreateCommand(
name = StoreMother.NAME,
address = StoreMother.ADDRESS
)
val content = objectMapper.writeValueAsString(command)

// when & then
Expand Down Expand Up @@ -95,7 +98,7 @@ class StoreControllerMvcTest : AbstractMockMvcTest() {
// when & then
mockMvc.perform(
RestDocumentationRequestBuilders.get(
"$BASE_URI?storeId={storeId}&size={size}&categoryId={categoryId}",
"$BASE_URI?cursor={cursor}&size={size}&categoryId={categoryId}",
storeDtos.size + 1,
pageSize,
null
Expand All @@ -114,7 +117,7 @@ class StoreControllerMvcTest : AbstractMockMvcTest() {
.tag("store")
.description("커서 기반 카테고리 가게 조회")
.queryParameters(
ResourceDocumentation.parameterWithName("storeId").description("조회한 마지막 가게 식별자").optional(),
ResourceDocumentation.parameterWithName("cursor").description("조회한 마지막 가게 식별자").optional(),
ResourceDocumentation.parameterWithName("categoryId").description("조회하는 가게의 카테고리의 식별자").optional(),
ResourceDocumentation.parameterWithName("size").description("조회할 페이지 사이즈").optional()
)
Expand Down Expand Up @@ -154,7 +157,7 @@ class StoreControllerMvcTest : AbstractMockMvcTest() {
// when & then
mockMvc.perform(
RestDocumentationRequestBuilders.get(
"$BASE_URI?storeId={storeId}&size={size}&categoryId={categoryId}",
"$BASE_URI?cursor={cursor}&size={size}&categoryId={categoryId}",
storeDtos.size + 1,
pageSize,
1
Expand Down

0 comments on commit f953696

Please sign in to comment.