Skip to content

Commit

Permalink
🔀 :: where절 날짜 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongho1209 committed Sep 7, 2023
1 parent ebaa37f commit eacbe85
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface QueryStatusSpi {

fun queryMovementStudentStatusIdByStudentIdAndToday(studentId: UUID): UUID?

fun queryStatusTypesByStudentIdAndEndPeriod(studentId: UUID, period: Int): List<StatusType>
fun queryStatusTypesByStudentIdAndEndPeriodAndToday(studentId: UUID, period: Int): List<StatusType>

fun queryMovementStatusListByTodayAndClassroomId(classroomId: UUID): List<Status>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ClassroomMovementUseCase(
val time = timeList.timeList.find { time -> time.period == request.period }
?: throw TimeNotFoundException

val statusTypes = queryStatusSpi.queryStatusTypesByStudentIdAndEndPeriod(
val statusTypes = queryStatusSpi.queryStatusTypesByStudentIdAndEndPeriodAndToday(
studentId = student.id,
period = request.period,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,14 @@ class StatusPersistenceAdapter(
)
.fetchOne()

override fun queryStatusTypesByStudentIdAndEndPeriod(studentId: UUID, period: Int): List<StatusType> =
override fun queryStatusTypesByStudentIdAndEndPeriodAndToday(studentId: UUID, period: Int): List<StatusType> =
jpaQueryFactory
.select(statusEntity.type)
.from(statusEntity)
.where(
statusEntity.studentId.eq(studentId),
statusEntity.endPeriod.lt(period), // 상태의 endPeriod < period면
statusEntity.date.eq(LocalDate.now())
)
.fetch()

Expand Down

0 comments on commit eacbe85

Please sign in to comment.