diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/spi/QueryTypeSpi.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/spi/QueryTypeSpi.kt index ff850d7a..5e28a967 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/spi/QueryTypeSpi.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/spi/QueryTypeSpi.kt @@ -7,7 +7,7 @@ import java.util.UUID interface QueryTypeSpi { - fun queryTypeListByToday(): List + fun queryTypeListByDate(startDate: LocalDate): List fun queryTypeById(typeId: UUID): Type diff --git a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/usecase/SelfStudyDirectorUseCase.kt b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/usecase/SelfStudyDirectorUseCase.kt index 0505729e..aeb30a16 100644 --- a/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/usecase/SelfStudyDirectorUseCase.kt +++ b/pick-application/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/usecase/SelfStudyDirectorUseCase.kt @@ -1,11 +1,8 @@ package com.pickdsm.pickserverspring.domain.selfstudydirector.usecase import com.pickdsm.pickserverspring.common.annotation.ReadOnlyUseCase -import com.pickdsm.pickserverspring.domain.application.spi.CommandStatusSpi -import com.pickdsm.pickserverspring.domain.application.spi.QueryStatusSpi import com.pickdsm.pickserverspring.domain.selfstudydirector.DirectorType import com.pickdsm.pickserverspring.domain.selfstudydirector.SelfStudyDirector -import com.pickdsm.pickserverspring.domain.selfstudydirector.Type import com.pickdsm.pickserverspring.domain.selfstudydirector.api.SelfStudyDirectorApi import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.requst.DomainChangeSelfStudyDirectorRequest import com.pickdsm.pickserverspring.domain.selfstudydirector.api.dto.response.SelfStudyElement @@ -36,23 +33,17 @@ class SelfStudyDirectorUseCase( val selfStudyDirectorList = querySelfStudyDirectorSpi.querySelfStudyDirectorByDate(startDate) val teacherIdList = selfStudyDirectorList.map { it.teacherId } val userInfoList = userQuerySelfStudyDirectorSpi.queryUserInfo(teacherIdList) - val typeList = queryTypeSpi.queryTypeListByToday() + val typeList = queryTypeSpi.queryTypeListByDate(startDate) // 해당 달의 1일부터 마지막일까지 반복문을 돌면서 값 가공 val selfStudyDirectorResponseList = (1..startDate.lengthOfMonth()) - .filter { i -> - selfStudyDirectorList.find { - val type = typeList.find { type -> type.id == it.typeId } ?: throw TypeNotFoundException - type.date != LocalDate.of(startDate.year, startDate.month, i) - } == null - } .map { i -> val date = LocalDate.of(startDate.year, startDate.month, i) - val directorType: DirectorType = typeList.find { it.date == date }?.type ?: DirectorType.SELF_STUDY + val directorType = typeList.find { it.date == date }?.type ?: DirectorType.SELF_STUDY val teacher = MutableList(5) { "" } selfStudyDirectorList.filter { - val type: Type = typeList.find { type -> type.id == it.typeId } ?: throw TypeNotFoundException + val type = typeList.find { type -> type.id == it.typeId } ?: throw TypeNotFoundException type.date == date }.map { selfStudy -> teacher[selfStudy.floor - 1] = userInfoList.find { it.id == selfStudy.teacherId }?.name ?: "" @@ -102,8 +93,9 @@ class SelfStudyDirectorUseCase( } override fun changeSelfStudyDirector(request: DomainChangeSelfStudyDirectorRequest) { - val selfStudyDirector = querySelfStudyDirectorSpi.querySelfStudyDirectorByDateAndFloor(request.date, request.floor) - ?: throw SelfStudyDirectorNotFoundException + val selfStudyDirector = + querySelfStudyDirectorSpi.querySelfStudyDirectorByDateAndFloor(request.date, request.floor) + ?: throw SelfStudyDirectorNotFoundException commandSelfStudyDirectorSpi.updateSelfStudyDirector( selfStudyDirector.changeSelfStudyDirector(teacherId = request.teacherId), diff --git a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/persistence/adapter/SelfStudyDirectorPersistenceAdapter.kt b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/persistence/adapter/SelfStudyDirectorPersistenceAdapter.kt index cf475c65..0c60d71b 100644 --- a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/persistence/adapter/SelfStudyDirectorPersistenceAdapter.kt +++ b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/persistence/adapter/SelfStudyDirectorPersistenceAdapter.kt @@ -26,7 +26,7 @@ class SelfStudyDirectorPersistenceAdapter( override fun querySelfStudyDirectorByDate(date: LocalDate): List = jpaQueryFactory .selectFrom(selfStudyDirectorEntity) - .innerJoin(selfStudyDirectorEntity.typeEntity, typeEntity) + .join(typeEntity) .on(selfStudyDirectorEntity.typeEntity.id.eq(typeEntity.id)) .where(typeEntity.date.between(date, date.plusMonths(1))) .fetch() diff --git a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/persistence/adapter/TypePersistenceAdapter.kt b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/persistence/adapter/TypePersistenceAdapter.kt index cafcb563..0ffa0c3a 100644 --- a/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/persistence/adapter/TypePersistenceAdapter.kt +++ b/pick-infrastructure/src/main/kotlin/com/pickdsm/pickserverspring/domain/selfstudydirector/persistence/adapter/TypePersistenceAdapter.kt @@ -19,10 +19,10 @@ class TypePersistenceAdapter( private val typeRepository: TypeRepository, ) : TypeSpi { - override fun queryTypeListByToday(): List = + override fun queryTypeListByDate(startDate: LocalDate): List = jpaQueryFactory .selectFrom(typeEntity) - .where(typeEntity.date.eq(LocalDate.now())) + .where(typeEntity.date.between(startDate, startDate.plusMonths(1))) .fetch() .map(typeMapper::entityToDomain)