Skip to content

Commit

Permalink
V0.1.9 (#86)
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)

* swagger 수정 (#83)

* [fix] redis 분리 및 api 추가 (#85)

---------

Co-authored-by: Bokyeom <[email protected]>
Co-authored-by: YOON <[email protected]>
Co-authored-by: Gopistol <[email protected]>
Co-authored-by: k-kbk <[email protected]>
  • Loading branch information
5 people authored Jan 14, 2024
1 parent f953696 commit c19ef3b
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .run/EatdaApplication.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ tasks.jacocoTestCoverageVerification {
"*.common.*",
"*.dto.*",
"com.mjucow.eatda.jooq.*",
"*.Companion"
"*.Companion",
"*.popularstore.*" // FIXME: redis 이슈 해결 후 제거'[
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.mjucow.eatda.domain.notice.service.command.dto

import io.swagger.v3.oas.annotations.media.Schema

data class CreateNoticeCommand(
@Schema(name = "title", example = "공지사항 제목")
val title: String,
@Schema(name = "content", example = "공지사항 내용")
val content: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ package com.mjucow.eatda.domain.store.service.command.dto
import io.swagger.v3.oas.annotations.media.Schema

data class CreateCommand(
@Schema(description = "생성할 카테고리 이름", example = "validName")
@Schema(name = "name", description = "생성할 카테고리 이름", example = "validName")
val name: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.mjucow.eatda.common.vo.Point
import io.swagger.v3.oas.annotations.media.Schema

data class StoreUpdateCommand(
@Schema(name = "Store Name", example = "명지대학교")
@Schema(name = "name", example = "명지대학교")
val name: String,
@Schema(name = "address", example = "서울특별시 서대문구 거북골로 34")
val address: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.mjucow.eatda.domain.store.service.query

import com.mjucow.eatda.domain.poplarstore.service.PopularStoreCommandService
import com.mjucow.eatda.domain.store.service.query.dto.StoreDetailDto
import com.mjucow.eatda.domain.store.service.query.dto.StoreDto
import com.mjucow.eatda.persistence.store.StoreRepository
Expand All @@ -11,7 +10,7 @@ import org.springframework.transaction.annotation.Transactional
@Transactional(readOnly = true)
class StoreQueryService(
val repository: StoreRepository,
val popularStoreCommandService: PopularStoreCommandService,
// val popularStoreCommandService: PopularStoreCommandService,
) {
fun findAllByCategoryAndCursor(cursor: Long? = null, categoryId: Long? = null, size: Int): List<StoreDto> {
return if (categoryId == null) {
Expand All @@ -33,7 +32,8 @@ class StoreQueryService(
fun findById(storeId: Long): StoreDetailDto {
val entity = repository.getReferenceById(storeId)
// FIXME(async): findById가 popular store command 과정에서 실패하지 않도록 비동기 호출 처리
popularStoreCommandService.setStore(storeId)
// TODO: Redis 이슈 해결 후 주석 제거
// popularStoreCommandService.setStore(storeId)
return StoreDetailDto.from(entity)
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
package com.mjucow.eatda.presentation.store.popularstore

import com.mjucow.eatda.domain.poplarstore.service.PopularStoreCacheService
import com.mjucow.eatda.domain.poplarstore.service.PopularStoreQueryService
import com.mjucow.eatda.domain.poplarstore.service.dto.PopularStoreDtos
import com.mjucow.eatda.presentation.common.ApiResponse
import org.springframework.http.HttpStatus
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.RequestMapping
import org.springframework.web.bind.annotation.ResponseStatus
import org.springframework.web.bind.annotation.RestController
import java.time.Instant

@RequestMapping("/api/v1/stores/popular")
@RestController
class PopularStoreController(
private val cacheService: PopularStoreCacheService,
private val queryService: PopularStoreQueryService,
) : PopularStoreApiPresentation {
@GetMapping
@ResponseStatus(HttpStatus.OK)
override fun findAllPopularStore(): ApiResponse<PopularStoreDtos> {
return ApiResponse.success(queryService.getPopularStores())
}

@PostMapping("/cache/{storeId}")
@ResponseStatus(HttpStatus.NO_CONTENT)
fun setRedis(@PathVariable storeId: String) {
cacheService.setStore(Instant.now(), storeId.toLong())
}

@GetMapping("/cache/{storeId}")
@ResponseStatus(HttpStatus.OK)
fun getRedis(@PathVariable storeId: String): ApiResponse<RedisCache?> {
val key = cacheService.createSearchKey(Instant.now())
val popularStores = cacheService.getStoresSortByPopular(key)
if (popularStores.isEmpty()) {
return ApiResponse.success(null)
} else {
val e = popularStores[0]
return ApiResponse.success(RedisCache(e.storeId, e.count))
}
}

data class RedisCache(val storeId: Long, val count: Long)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mjucow.eatda.presentation.store.popularstore

import com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper
import com.epages.restdocs.apispec.ResourceSnippetParametersBuilder
import com.mjucow.eatda.domain.poplarstore.service.PopularStoreCacheService
import com.mjucow.eatda.domain.poplarstore.service.PopularStoreQueryService
import com.mjucow.eatda.domain.poplarstore.service.dto.PopularStoreDtos
import com.mjucow.eatda.presentation.AbstractMockMvcTest
Expand All @@ -18,6 +19,9 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers

@WebMvcTest(PopularStoreController::class)
class PopularStoreControllerTest : AbstractMockMvcTest() {
@MockkBean(relaxUnitFun = true)
lateinit var cacheService: PopularStoreCacheService

@MockkBean(relaxUnitFun = true)
lateinit var popularStoreQueryService: PopularStoreQueryService

Expand Down

0 comments on commit c19ef3b

Please sign in to comment.