Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #332 from GSM-MSG/feature/325-already-exist-attend…
Browse files Browse the repository at this point in the history
…ance

출석부 중복 생성 예외 pr에 빠진 코드리뷰 반영
  • Loading branch information
ani2689 authored Apr 16, 2024
2 parents 69b0a72 + c4c6edb commit 7dd9063
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import java.time.LocalDate

interface CustomScheduleRepository {
fun queryByDate(club: Club, date: LocalDate?): Schedule?
fun existByDateAndPeriod(date: LocalDate, period: Period): Boolean
fun existByDateAndPeriods(date: LocalDate, period: List<Period>): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ class CustomScheduleRepositoryImpl(
).fetchOne()
}

override fun existByDateAndPeriod(date: LocalDate, period: Period): Boolean {
override fun existByDateAndPeriods(date: LocalDate, period: List<Period>): Boolean {
return jpaQueryFactory.selectOne()
.from(attendance)
.leftJoin(attendance.schedule, schedule)
.where(
attendance.schedule.date.eq(date),
attendance.period.eq(period)
attendance.period.`in`(period)
)
.fetchFirst() != null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class CreateScheduleServiceImpl(
val schedule = scheduleConverter.toEntity(club, dto.schedule)
.let { scheduleRepository.save(it) }

if(scheduleRepository.existByDateAndPeriods(dto.schedule.date, dto.period))
throw AlreadyScheduleExistException()

val attendances = dto.period.flatMap { period ->
if(scheduleRepository.existByDateAndPeriod(dto.schedule.date, period))
throw AlreadyScheduleExistException()

members.map { member ->
attendanceConverter.toEntity(
Expand Down

0 comments on commit 7dd9063

Please sign in to comment.