Skip to content

Commit

Permalink
refactor: (#176) Menu → Menus 메소드 명 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Dec 5, 2022
1 parent f97781f commit 001815a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class QueryMenuByMonthUseCase(
val currentUserId = menuSecurityPort.getCurrentUserId()
val user = queryUserPort.queryUserById(currentUserId) ?: throw UserNotFoundException.EXCEPTION

val menu = queryMenuPort.queryMenuByMonthAndSpotId(date, user.spotId)
val menu = queryMenuPort.queryMenusByMonthAndSpotId(date, user.spotId)
val result = menu.map { MenuResponse.MenuElement(it.date, it.meal) }

return MenuResponse(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class QueryPublicMenuUseCase(
) {

fun execute(date: LocalDate): MenuResponse {
val menu = queryMenuPort.queryMenuByMonthAndSpotName(date, Spot.HEAD_SHOP)
val menu = queryMenuPort.queryMenusByMonthAndSpotName(date, Spot.HEAD_SHOP)
val result = menu.map { MenuResponse.MenuElement(it.date, it.meal) }

return MenuResponse(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class QueryMenuByMonthUseCaseTests {
given(queryUserPort.queryUserById(currentUserId))
.willReturn(userStub)

given(queryMenuPort.queryMenuByMonthAndSpotId(now, userStub.spotId))
given(queryMenuPort.queryMenusByMonthAndSpotId(now, userStub.spotId))
.willReturn(
listOf(menuStub, menuStub2)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class QueryPublicMenuUseCaseTests {
fun `메뉴 조회 성공`() {
// given
val now = LocalDate.now()
given(queryMenuPort.queryMenuByMonthAndSpotName(now, Spot.HEAD_SHOP))
given(queryMenuPort.queryMenusByMonthAndSpotName(now, Spot.HEAD_SHOP))
.willReturn(
listOf(menuStub, menuStub2)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import java.util.UUID
**/
interface QueryMenuPort {

fun queryMenuByMonthAndSpotId(date: LocalDate, spotId: UUID): List<Menu>
fun queryMenusByMonthAndSpotId(date: LocalDate, spotId: UUID): List<Menu>

fun queryMenuByMonthAndSpotName(date: LocalDate, spotName: String): List<Menu>
fun queryMenusByMonthAndSpotName(date: LocalDate, spotName: String): List<Menu>

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,30 @@ class MenuPersistenceAdapter(
private val queryFactory: JPAQueryFactory
) : MenuPort {

override fun queryMenuByMonthAndSpotId(date: LocalDate, spotId: UUID): List<Menu> {
override fun queryMenusByMonthAndSpotId(date: LocalDate, spotId: UUID): List<Menu> {
return queryFactory
.selectFrom(menuJpaEntity)
.join(menuJpaEntity.spot, spotJpaEntity)
.on(spotJpaEntity.id.eq(spotId))
.where(
sameMonthMenuFilter(date)
)
.orderBy(menuJpaEntity.id.date.asc())
.fetch()
.map {
menuMapper.toDomain(it)!!
}
.map { menuMapper.toDomain(it)!! }
}

override fun queryMenuByMonthAndSpotName(date: LocalDate, spotName: String): List<Menu> {
override fun queryMenusByMonthAndSpotName(date: LocalDate, spotName: String): List<Menu> {
return queryFactory
.selectFrom(menuJpaEntity)
.join(menuJpaEntity.spot, spotJpaEntity)
.on(spotJpaEntity.name.eq(spotName))
.where(
sameMonthMenuFilter(date)
)
.orderBy(menuJpaEntity.id.date.asc())
.fetch()
.map {
menuMapper.toDomain(it)!!
}
.map { menuMapper.toDomain(it)!! }
}

private fun sameMonthMenuFilter(date: LocalDate) : BooleanExpression {
Expand Down

0 comments on commit 001815a

Please sign in to comment.