From 59a50e15a11b0536d26d9852035452cef2cbaf4b Mon Sep 17 00:00:00 2001 From: min56 Date: Sun, 23 Apr 2023 13:24:06 +0900 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=93=91=20::=20AlreadyPicnicAwaitExcep?= =?UTF-8?q?tion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/application/error/ApplicationErrorCode.kt | 3 ++- .../application/exception/AlreadyPicnicAwaitException.kt | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyPicnicAwaitException.kt diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/error/ApplicationErrorCode.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/error/ApplicationErrorCode.kt index d01c570a..558533ed 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/error/ApplicationErrorCode.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/error/ApplicationErrorCode.kt @@ -7,7 +7,8 @@ enum class ApplicationErrorCode( private val message: String, ) : ErrorProperty { - APPLICATION_NOT_FOUND(404, "Application Not Found"), ; + APPLICATION_NOT_FOUND(404, "Application Not Found"), + AlREADY_PICNIC_AWAIT(409, "Already picnic Await"), ; override fun status() = status override fun message() = message diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyPicnicAwaitException.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyPicnicAwaitException.kt new file mode 100644 index 00000000..7767231b --- /dev/null +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyPicnicAwaitException.kt @@ -0,0 +1,8 @@ +package com.pickdsm.pickserverspring.domain.application.exception + +import com.pickdsm.pickserverspring.common.error.PickException +import com.pickdsm.pickserverspring.domain.application.error.ApplicationErrorCode + +object AlreadyPicnicAwaitException : PickException ( + ApplicationErrorCode.AlREADY_PICNIC_AWAIT +) \ No newline at end of file From 83389be3ca1f663ca736d89e13d0da7078d30d9f Mon Sep 17 00:00:00 2001 From: min56 Date: Sun, 23 Apr 2023 13:25:09 +0900 Subject: [PATCH 2/9] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20queryApplicationB?= =?UTF-8?q?yStudentId=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/application/spi/QueryApplicationSpi.kt | 2 ++ .../persistence/adapter/ApplicationPersistenceAdapter.kt | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryApplicationSpi.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryApplicationSpi.kt index ab512dfd..97b0664b 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryApplicationSpi.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryApplicationSpi.kt @@ -11,4 +11,6 @@ interface QueryApplicationSpi { fun queryApplicationListByToday(date: LocalDate): List fun queryApplicationByStudentIdAndStatusId(studentId: UUID, statusId: UUID): Application? + + fun queryApplicationByStudentId(studentId:UUID): Boolean } diff --git a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt index 4dba1f4d..ed4d9ba9 100644 --- a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt +++ b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt @@ -8,8 +8,9 @@ import com.pickdsm.pickserverspring.domain.application.persistence.entity.QStatu import com.pickdsm.pickserverspring.domain.application.spi.ApplicationSpi import com.pickdsm.pickserverspring.global.annotation.Adapter import com.querydsl.jpa.impl.JPAQueryFactory +import org.springframework.data.repository.findByIdOrNull import java.time.LocalDate -import java.util.UUID +import java.util.* @Adapter class ApplicationPersistenceAdapter( @@ -46,4 +47,8 @@ class ApplicationPersistenceAdapter( .where(statusEntity.studentId.eq(studentId)) .fetchFirst() ?.let(applicationMapper::entityToDomain) + + override fun queryApplicationByStudentId(studentId: UUID): Boolean { + return applicationRepository.findById(studentId).isEmpty + } } From ce9a315faa37a22e03743a8f2db3203ec828162c Mon Sep 17 00:00:00 2001 From: min56 Date: Sun, 23 Apr 2023 13:25:24 +0900 Subject: [PATCH 3/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=EB=AC=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/application/usecase/ApplicationUseCase.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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 a1b73d33..0c0e9469 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 @@ -17,6 +17,7 @@ import com.pickdsm.pickserverspring.domain.application.api.dto.response.QueryPic import com.pickdsm.pickserverspring.domain.application.api.dto.response.QueryPicnicStudentList import com.pickdsm.pickserverspring.domain.application.api.dto.response.QueryStudentStatusElement import com.pickdsm.pickserverspring.domain.application.api.dto.response.QueryStudentStatusList +import com.pickdsm.pickserverspring.domain.application.exception.AlreadyPicnicAwaitException import com.pickdsm.pickserverspring.domain.application.exception.ApplicationNotFoundException import com.pickdsm.pickserverspring.domain.application.exception.StatusNotFoundException import com.pickdsm.pickserverspring.domain.application.spi.CommandApplicationSpi @@ -62,6 +63,11 @@ class ApplicationUseCase( endPeriod = request.desiredEndPeriod, type = StatusType.AWAIT, ) + + if(!queryApplicationSpi.queryApplicationByStudentId(studentId)) { + throw AlreadyPicnicAwaitException + } + val saveStatusId = statusCommandTeacherSpi.saveStatusAndGetStatusId(status) commandApplicationSpi.saveApplication( Application( From b14dae5744f97acc352d795d013fdc86a827907a Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 13:46:40 +0900 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=93=91=20::=20ApplicationErrorCode=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/application/error/ApplicationErrorCode.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/error/ApplicationErrorCode.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/error/ApplicationErrorCode.kt index 558533ed..cf16813b 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/error/ApplicationErrorCode.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/error/ApplicationErrorCode.kt @@ -7,8 +7,11 @@ enum class ApplicationErrorCode( private val message: String, ) : ErrorProperty { + CANNOT_APPLICATION_WEEKEND(401, "Cannot Application Weekend"), + APPLICATION_NOT_FOUND(404, "Application Not Found"), - AlREADY_PICNIC_AWAIT(409, "Already picnic Await"), ; + + ALREADY_APPLICATION_PICNIC_OR_ALREADY_PICNIC(409, "Already Application Picnic Or Already Picnic"), ; override fun status() = status override fun message() = message From da9a3c90e30e9388897bf676e94043bf098f0131 Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 13:46:58 +0900 Subject: [PATCH 5/9] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20Exception=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AlreadyApplicationPicnicOrAlreadyPicnicException.kt | 8 ++++++++ ...tException.kt => CannotApplicationWeekendException.kt} | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyApplicationPicnicOrAlreadyPicnicException.kt rename pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/{AlreadyPicnicAwaitException.kt => CannotApplicationWeekendException.kt} (65%) diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyApplicationPicnicOrAlreadyPicnicException.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyApplicationPicnicOrAlreadyPicnicException.kt new file mode 100644 index 00000000..7ac2c737 --- /dev/null +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyApplicationPicnicOrAlreadyPicnicException.kt @@ -0,0 +1,8 @@ +package com.pickdsm.pickserverspring.domain.application.exception + +import com.pickdsm.pickserverspring.common.error.PickException +import com.pickdsm.pickserverspring.domain.application.error.ApplicationErrorCode + +object AlreadyApplicationPicnicOrAlreadyPicnicException : PickException( + ApplicationErrorCode.ALREADY_APPLICATION_PICNIC_OR_ALREADY_PICNIC, +) diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyPicnicAwaitException.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/CannotApplicationWeekendException.kt similarity index 65% rename from pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyPicnicAwaitException.kt rename to pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/CannotApplicationWeekendException.kt index 7767231b..c46eebf1 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/AlreadyPicnicAwaitException.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/exception/CannotApplicationWeekendException.kt @@ -3,6 +3,6 @@ package com.pickdsm.pickserverspring.domain.application.exception import com.pickdsm.pickserverspring.common.error.PickException import com.pickdsm.pickserverspring.domain.application.error.ApplicationErrorCode -object AlreadyPicnicAwaitException : PickException ( - ApplicationErrorCode.AlREADY_PICNIC_AWAIT -) \ No newline at end of file +object CannotApplicationWeekendException : PickException( + ApplicationErrorCode.CANNOT_APPLICATION_WEEKEND, +) From cad5d860c5d68d7502e3beacc0b81d2f11ce9968 Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 13:47:20 +0900 Subject: [PATCH 6/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=95=88=20?= =?UTF-8?q?=EC=93=B0=EB=8A=94=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/application/spi/QueryApplicationSpi.kt | 2 -- .../persistence/adapter/ApplicationPersistenceAdapter.kt | 9 +++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryApplicationSpi.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryApplicationSpi.kt index 97b0664b..ab512dfd 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryApplicationSpi.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/spi/QueryApplicationSpi.kt @@ -11,6 +11,4 @@ interface QueryApplicationSpi { fun queryApplicationListByToday(date: LocalDate): List fun queryApplicationByStudentIdAndStatusId(studentId: UUID, statusId: UUID): Application? - - fun queryApplicationByStudentId(studentId:UUID): Boolean } diff --git a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt index ed4d9ba9..2dca345e 100644 --- a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt +++ b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt @@ -1,16 +1,17 @@ package com.pickdsm.pickserverspring.domain.application.persistence.adapter import com.pickdsm.pickserverspring.domain.application.Application +import com.pickdsm.pickserverspring.domain.application.StatusType import com.pickdsm.pickserverspring.domain.application.mapper.ApplicationMapper import com.pickdsm.pickserverspring.domain.application.persistence.ApplicationRepository import com.pickdsm.pickserverspring.domain.application.persistence.entity.QApplicationEntity.applicationEntity import com.pickdsm.pickserverspring.domain.application.persistence.entity.QStatusEntity.statusEntity import com.pickdsm.pickserverspring.domain.application.spi.ApplicationSpi import com.pickdsm.pickserverspring.global.annotation.Adapter +import com.querydsl.core.types.dsl.BooleanExpression import com.querydsl.jpa.impl.JPAQueryFactory -import org.springframework.data.repository.findByIdOrNull import java.time.LocalDate -import java.util.* +import java.util.UUID @Adapter class ApplicationPersistenceAdapter( @@ -47,8 +48,4 @@ class ApplicationPersistenceAdapter( .where(statusEntity.studentId.eq(studentId)) .fetchFirst() ?.let(applicationMapper::entityToDomain) - - override fun queryApplicationByStudentId(studentId: UUID): Boolean { - return applicationRepository.findById(studentId).isEmpty - } } From 50cad0c1efb3a625a7e968d8d13441296ff3619c Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 13:47:53 +0900 Subject: [PATCH 7/9] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20::=20=EB=8C=80?= =?UTF-8?q?=EA=B8=B0=20=EC=83=81=ED=83=9C=20or=20=EC=99=B8=EC=B6=9C=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=EB=A1=9C=20=EC=A1=B4=EC=9E=AC=ED=95=98?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8=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 ++ .../adapter/StatusPersistenceAdapter.kt | 14 ++++++++++++++ 2 files changed, 16 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 80c23328..cc88c78e 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 @@ -36,4 +36,6 @@ interface QueryStatusSpi { fun queryMovementStatusSizeByFloorAndToday(floor: Int): Int fun queryPicnicStatusSizeByToday(): Int + + fun existAwaitOrPicnicStatusByStudentId(studentId: UUID): Boolean } 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 65308dab..835fdfd0 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 @@ -9,6 +9,7 @@ import com.pickdsm.pickserverspring.domain.application.spi.StatusSpi import com.pickdsm.pickserverspring.domain.classroom.persistence.entity.QClassroomEntity.classroomEntity import com.pickdsm.pickserverspring.domain.classroom.persistence.entity.QClassroomMovementEntity.classroomMovementEntity import com.pickdsm.pickserverspring.global.annotation.Adapter +import com.querydsl.core.types.dsl.BooleanExpression import com.querydsl.jpa.impl.JPAQueryFactory import java.time.LocalDate import java.util.UUID @@ -188,4 +189,17 @@ class StatusPersistenceAdapter( statusEntity.type.eq(StatusType.PICNIC), ) .fetch().size + + override fun existAwaitOrPicnicStatusByStudentId(studentId: UUID): Boolean = + jpaQueryFactory + .select(statusEntity.id) + .from(statusEntity) + .where( + checkIsExistAwaitOrPicnic(), + statusEntity.studentId.eq(studentId), + ) + .fetchFirst() != null + + private fun checkIsExistAwaitOrPicnic(): BooleanExpression = + statusEntity.type.eq(StatusType.AWAIT).or(statusEntity.type.eq(StatusType.PICNIC)) } From c934dce3530deade6d1786dba1ba967dc2b8f7b7 Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 13:48:39 +0900 Subject: [PATCH 8/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20=EC=99=B8?= =?UTF-8?q?=EC=B6=9C=20=EC=8B=A0=EC=B2=AD=20=EC=A4=91=EB=B3=B5=20&&=20?= =?UTF-8?q?=EC=A3=BC=EB=A7=90=20=EC=8B=A0=EC=B2=AD=20=ED=95=B8=EB=93=A4?= =?UTF-8?q?=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/ApplicationUseCase.kt | 24 ++++++++++++++----- 1 file changed, 18 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 0c0e9469..2f739559 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 @@ -17,8 +17,9 @@ import com.pickdsm.pickserverspring.domain.application.api.dto.response.QueryPic import com.pickdsm.pickserverspring.domain.application.api.dto.response.QueryPicnicStudentList import com.pickdsm.pickserverspring.domain.application.api.dto.response.QueryStudentStatusElement import com.pickdsm.pickserverspring.domain.application.api.dto.response.QueryStudentStatusList -import com.pickdsm.pickserverspring.domain.application.exception.AlreadyPicnicAwaitException +import com.pickdsm.pickserverspring.domain.application.exception.AlreadyApplicationPicnicOrAlreadyPicnicException import com.pickdsm.pickserverspring.domain.application.exception.ApplicationNotFoundException +import com.pickdsm.pickserverspring.domain.application.exception.CannotApplicationWeekendException import com.pickdsm.pickserverspring.domain.application.exception.StatusNotFoundException import com.pickdsm.pickserverspring.domain.application.spi.CommandApplicationSpi import com.pickdsm.pickserverspring.domain.application.spi.QueryApplicationSpi @@ -35,6 +36,7 @@ import com.pickdsm.pickserverspring.domain.teacher.spi.TimeQueryTeacherSpi import com.pickdsm.pickserverspring.domain.time.exception.TimeNotFoundException import com.pickdsm.pickserverspring.domain.user.exception.UserNotFoundException import com.pickdsm.pickserverspring.domain.user.spi.UserSpi +import java.time.DayOfWeek import java.time.LocalDate import java.util.UUID @@ -56,6 +58,9 @@ class ApplicationUseCase( override fun saveApplicationToGoOut(request: DomainApplicationGoOutRequest) { val studentId = userSpi.getCurrentUserId() + checkIsExistAwaitOrPicnicStatus(studentId) + checkIsWeekends() + val status = Status( studentId = studentId, teacherId = UUID(0, 0), // TODO: 선생님 아이디 뭐로 넣을지 나중에 정하기 @@ -63,11 +68,6 @@ class ApplicationUseCase( endPeriod = request.desiredEndPeriod, type = StatusType.AWAIT, ) - - if(!queryApplicationSpi.queryApplicationByStudentId(studentId)) { - throw AlreadyPicnicAwaitException - } - val saveStatusId = statusCommandTeacherSpi.saveStatusAndGetStatusId(status) commandApplicationSpi.saveApplication( Application( @@ -77,6 +77,18 @@ class ApplicationUseCase( ) } + private fun checkIsExistAwaitOrPicnicStatus(studentId: UUID) { + if (queryStatusSpi.existAwaitOrPicnicStatusByStudentId(studentId)) { + throw AlreadyApplicationPicnicOrAlreadyPicnicException + } + } + + private fun checkIsWeekends() { + if (LocalDate.now().dayOfWeek > DayOfWeek.FRIDAY) { + throw CannotApplicationWeekendException + } + } + override fun queryPicnicApplicationListByGradeAndClassNum( grade: String?, classNum: String?, From c4ce32a78b018c32685a2a0f4a1792ba2a4b50ca Mon Sep 17 00:00:00 2001 From: jungho1209 Date: Sun, 23 Apr 2023 13:52:30 +0900 Subject: [PATCH 9/9] =?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 --- .../persistence/adapter/ApplicationPersistenceAdapter.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt index 2dca345e..4dba1f4d 100644 --- a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt +++ b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/application/persistence/adapter/ApplicationPersistenceAdapter.kt @@ -1,14 +1,12 @@ package com.pickdsm.pickserverspring.domain.application.persistence.adapter import com.pickdsm.pickserverspring.domain.application.Application -import com.pickdsm.pickserverspring.domain.application.StatusType import com.pickdsm.pickserverspring.domain.application.mapper.ApplicationMapper import com.pickdsm.pickserverspring.domain.application.persistence.ApplicationRepository import com.pickdsm.pickserverspring.domain.application.persistence.entity.QApplicationEntity.applicationEntity import com.pickdsm.pickserverspring.domain.application.persistence.entity.QStatusEntity.statusEntity import com.pickdsm.pickserverspring.domain.application.spi.ApplicationSpi import com.pickdsm.pickserverspring.global.annotation.Adapter -import com.querydsl.core.types.dsl.BooleanExpression import com.querydsl.jpa.impl.JPAQueryFactory import java.time.LocalDate import java.util.UUID