-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 세션에 출석 코드 추가 * feat: 코드를 이용한 출석 처리 로직 구현 - 기본적인 출석 체크의 검증 로직과 유사하고, 오프라인의 경우에만 작동하도록 validation * feat: 마스킹 로직에 code 추가 * chore: Session.code, Attendance.try_count 추가 dml 작성 * feat: 재시도 로직 추가 * chore: 스웨거에 에러 응답 추가 * test: code 추가 및 masking 로직에 따른 테스트 코드 수정 * test: code 추가 및 masking 로직에 따른 테스트 코드 추가 * fix: 잘못 주입되는 gateway 변경 * feat: 오프라인 세션의 출석 코드 방식 테스트 코드 추가 * chore: 스웨거에 마스킹 설명 추가 * chore: 스웨거에 마스킹 설명 변경 * chore: 정책에 따른 출석 에러 메시지 변경
- Loading branch information
Showing
19 changed files
with
440 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/kotlin/com/depromeet/makers/domain/usecase/CheckInSessionWithCode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.depromeet.makers.domain.usecase | ||
|
||
import com.depromeet.makers.domain.exception.* | ||
import com.depromeet.makers.domain.gateway.AttendanceGateway | ||
import com.depromeet.makers.domain.gateway.MemberGateway | ||
import com.depromeet.makers.domain.gateway.SessionGateway | ||
import com.depromeet.makers.domain.model.Attendance | ||
import java.time.DayOfWeek | ||
import java.time.LocalDateTime | ||
|
||
class CheckInSessionWithCode( | ||
private val attendanceGateway: AttendanceGateway, | ||
private val sessionGateway: SessionGateway, | ||
private val memberGateway: MemberGateway, | ||
) : UseCase<CheckInSessionWithCode.CheckInSessionWithCodeInput, Attendance> { | ||
data class CheckInSessionWithCodeInput( | ||
val memberId: String, | ||
val now: LocalDateTime, | ||
val code: String, | ||
) | ||
|
||
override fun execute(input: CheckInSessionWithCodeInput): Attendance { | ||
val member = memberGateway.getById(input.memberId) | ||
val monday = input.now.getMonday() | ||
|
||
val thisWeekSession = | ||
sessionGateway.findByStartTimeBetween( | ||
monday, | ||
monday.plusDays(7), | ||
) ?: throw InvalidCheckInTimeException() | ||
|
||
if (thisWeekSession.isOnline()) { | ||
throw NotSupportedCheckInCodeException() | ||
} | ||
|
||
val attendance = | ||
runCatching { | ||
attendanceGateway.findByMemberIdAndGenerationAndWeek( | ||
member.memberId, | ||
thisWeekSession.generation, | ||
thisWeekSession.week, | ||
) | ||
}.getOrElse { throw NotFoundAttendanceException() } | ||
|
||
if (attendance.isTryCountOver()) { | ||
throw TryCountOverException() | ||
} | ||
|
||
attendance.isAvailableCheckInRequest(thisWeekSession.startTime, input.now) | ||
|
||
if (thisWeekSession.code != input.code) { | ||
attendanceGateway.save(attendance.tryCountUp()) | ||
throw InvalidCheckInCodeException(attendance.getTryCount()) | ||
} | ||
|
||
val expectAttendanceStatus = attendance.expectAttendanceStatus(thisWeekSession.startTime, input.now) | ||
return attendanceGateway.save(attendance.checkIn(input.now, expectAttendanceStatus)) | ||
} | ||
|
||
private fun LocalDateTime.getMonday() = this.toLocalDate().with(DayOfWeek.MONDAY).atStartOfDay() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 79 additions & 19 deletions
98
src/main/kotlin/com/depromeet/makers/presentation/restapi/controller/CheckInController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.