From 3f9f8b6b48767bfdc8e501ec17d32899081ef2e2 Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 09:49:47 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EC=98=A4?= =?UTF-8?q?=EB=8A=98=20=EC=99=B8=EC=B6=9C=20=EC=83=81=ED=83=9C=EB=A7=8C=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EB=8A=94=20=EB=A9=94=EC=86=8C?= =?UTF-8?q?=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/application/spi/QueryStatusSpi.kt | 2 ++ .../persistence/adapter/StatusPersistenceAdapter.kt | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryStatusSpi.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryStatusSpi.kt index 5da769b6..80c23328 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryStatusSpi.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryStatusSpi.kt @@ -19,6 +19,8 @@ interface QueryStatusSpi { fun queryPicnicStudentByStudentId(studentId: UUID): Status? + fun queryPicnicStudentByStudentIdAndToday(studentId: UUID): Status? + fun queryStatusByStudentIdAndStartPeriodAndEndPeriod(studentId: UUID, startPeriod: Int, endPeriod: Int): Status? fun queryMovementStudentByStudentId(studentId: UUID): Status? diff --git a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/StatusPersistenceAdapter.kt b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/StatusPersistenceAdapter.kt index 99c14334..8b13525f 100644 --- a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/StatusPersistenceAdapter.kt +++ b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/StatusPersistenceAdapter.kt @@ -92,6 +92,17 @@ class StatusPersistenceAdapter( .fetchFirst() ?.let(statusMapper::entityToDomain) + override fun queryPicnicStudentByStudentIdAndToday(studentId: UUID): Status? = + jpaQueryFactory + .selectFrom(statusEntity) + .where( + statusEntity.studentId.eq(studentId), + statusEntity.type.eq(StatusType.PICNIC), + statusEntity.date.eq(LocalDate.now()) + ) + .fetchFirst() + ?.let(statusMapper::entityToDomain) + override fun queryStatusByStudentIdAndStartPeriodAndEndPeriod( studentId: UUID, startPeriod: Int, From 2b47ec6dadc54e066bb655940e71bda79b16a762 Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 09:50:30 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EC=88=98=EC=A0=95=20&&=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/application/usecase/ApplicationUseCase.kt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/usecase/ApplicationUseCase.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/usecase/ApplicationUseCase.kt index 2c059550..a1b73d33 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/usecase/ApplicationUseCase.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/usecase/ApplicationUseCase.kt @@ -466,9 +466,8 @@ class ApplicationUseCase( } override fun getMyPicnicEndTime(): QueryMyPicnicEndTimeResponse { - val userId = userSpi.getCurrentUserId() - val userInfo = userSpi.queryUserInfoByUserId(userId) - val picnicUserStatus = queryStatusSpi.queryPicnicStudentByStudentId(userId) + val userInfo = userSpi.queryUserInfoByUserId(userSpi.getCurrentUserId()) + val picnicUserStatus = queryStatusSpi.queryPicnicStudentByStudentIdAndToday(userInfo.id) ?: throw StatusNotFoundException val endTime = timeQueryTeacherSpi.queryTime(LocalDate.now()) .timeList.find { time -> time.period == picnicUserStatus.endPeriod }?.endTime @@ -482,9 +481,8 @@ class ApplicationUseCase( } override fun getMyPicnicInfo(): QueryMyPicnicInfoResponse { - val userId = userSpi.getCurrentUserId() - val userInfo = userSpi.queryUserInfoByUserId(userId) - val picnicUserStatus = queryStatusSpi.queryPicnicStudentByStudentId(userId) + val userInfo = userSpi.queryUserInfoByUserId(userSpi.getCurrentUserId()) + val picnicUserStatus = queryStatusSpi.queryPicnicStudentByStudentIdAndToday(userInfo.id) ?: throw StatusNotFoundException val teacherName = userSpi.queryUserInfoByUserId(picnicUserStatus.teacherId).name From 25bc3654393d51a4a85b605307670e8339dc2dcd Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 09:54:46 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20ktlint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/persistence/adapter/StatusPersistenceAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/StatusPersistenceAdapter.kt b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/StatusPersistenceAdapter.kt index 8b13525f..65308dab 100644 --- a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/StatusPersistenceAdapter.kt +++ b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/StatusPersistenceAdapter.kt @@ -98,7 +98,7 @@ class StatusPersistenceAdapter( .where( statusEntity.studentId.eq(studentId), statusEntity.type.eq(StatusType.PICNIC), - statusEntity.date.eq(LocalDate.now()) + statusEntity.date.eq(LocalDate.now()), ) .fetchFirst() ?.let(statusMapper::entityToDomain)