Skip to content

Commit

Permalink
๐Ÿ”€ :: (#22) ์™ธ์ถœ์ฆ ์กฐํšŒ ์˜ค๋Š˜๊ฒƒ๋งŒ ๊ฐ€์ ธ์˜ค๋„๋ก ์ˆ˜์ •
Browse files Browse the repository at this point in the history
๐Ÿ”€ :: (#22) ์™ธ์ถœ์ฆ ์กฐํšŒ ์˜ค๋Š˜๊ฒƒ๋งŒ ๊ฐ€์ ธ์˜ค๋„๋ก ์ˆ˜์ •
  • Loading branch information
jeongho1209 authored Apr 23, 2023
2 parents 3d3ad63 + 25bc365 commit f26709c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f26709c

Please sign in to comment.