diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCase.kt index 13b73d4c..f9c5f8d4 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCase.kt @@ -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) diff --git a/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCase.kt b/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCase.kt index 3ebd83ee..9f6ed746 100644 --- a/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCase.kt +++ b/simtong-application/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCase.kt @@ -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) diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt index c6b53b26..3689314f 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryMenuByMonthUseCaseTests.kt @@ -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) ) diff --git a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCaseTests.kt b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCaseTests.kt index 50a21939..cda0d71a 100644 --- a/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCaseTests.kt +++ b/simtong-application/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCaseTests.kt @@ -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) ) diff --git a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/spi/QueryMenuPort.kt b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/spi/QueryMenuPort.kt index 8b9416fb..61c67123 100644 --- a/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/spi/QueryMenuPort.kt +++ b/simtong-domain/src/main/kotlin/team/comit/simtong/domain/menu/spi/QueryMenuPort.kt @@ -15,8 +15,8 @@ import java.util.UUID **/ interface QueryMenuPort { - fun queryMenuByMonthAndSpotId(date: LocalDate, spotId: UUID): List + fun queryMenusByMonthAndSpotId(date: LocalDate, spotId: UUID): List - fun queryMenuByMonthAndSpotName(date: LocalDate, spotName: String): List + fun queryMenusByMonthAndSpotName(date: LocalDate, spotName: String): List } \ No newline at end of file diff --git a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/menu/MenuPersistenceAdapter.kt b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/menu/MenuPersistenceAdapter.kt index 239afeb3..d91f3a6a 100644 --- a/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/menu/MenuPersistenceAdapter.kt +++ b/simtong-infrastructure/src/main/kotlin/team/comit/simtong/persistence/menu/MenuPersistenceAdapter.kt @@ -27,7 +27,7 @@ class MenuPersistenceAdapter( private val queryFactory: JPAQueryFactory ) : MenuPort { - override fun queryMenuByMonthAndSpotId(date: LocalDate, spotId: UUID): List { + override fun queryMenusByMonthAndSpotId(date: LocalDate, spotId: UUID): List { return queryFactory .selectFrom(menuJpaEntity) .join(menuJpaEntity.spot, spotJpaEntity) @@ -35,13 +35,12 @@ class MenuPersistenceAdapter( .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 { + override fun queryMenusByMonthAndSpotName(date: LocalDate, spotName: String): List { return queryFactory .selectFrom(menuJpaEntity) .join(menuJpaEntity.spot, spotJpaEntity) @@ -49,10 +48,9 @@ class MenuPersistenceAdapter( .where( sameMonthMenuFilter(date) ) + .orderBy(menuJpaEntity.id.date.asc()) .fetch() - .map { - menuMapper.toDomain(it)!! - } + .map { menuMapper.toDomain(it)!! } } private fun sameMonthMenuFilter(date: LocalDate) : BooleanExpression {