Skip to content

Commit

Permalink
feat: 출석(체크인) 요청 성공 시 결과를 응답하도록 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ddingmin committed May 19, 2024
1 parent f733972 commit d375a45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class CheckInSession(
private val attendanceGateway: AttendanceGateway,
private val sessionGateway: SessionGateway,
private val memberGateway: MemberGateway,
) : UseCase<CheckInSession.CheckInSessionInput, Unit> {
) : UseCase<CheckInSession.CheckInSessionInput, Attendance> {
data class CheckInSessionInput(
val now: LocalDateTime,
val memberId: String,
val longitude: Double?,
val latitude: Double?,
)

override fun execute(input: CheckInSessionInput) {
override fun execute(input: CheckInSessionInput): Attendance {
val member = memberGateway.getById(input.memberId)
val monday = input.now.getMonday()

Expand Down Expand Up @@ -64,7 +64,7 @@ class CheckInSession(
}
}

attendanceGateway.save(attendance.checkIn(input.now, thisWeekSession.startTime))
return attendanceGateway.save(attendance.checkIn(input.now, thisWeekSession.startTime))
}

private fun LocalDateTime.getMonday() = this.toLocalDate().with(DayOfWeek.MONDAY).atStartOfDay()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package com.depromeet.makers.presentation.restapi.controller

import com.depromeet.makers.domain.usecase.CheckInSession
import com.depromeet.makers.domain.usecase.GetCheckInStatus
import com.depromeet.makers.presentation.restapi.dto.response.AttendanceResponse
import com.depromeet.makers.presentation.restapi.dto.response.CheckInStatusResponse
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.security.core.Authentication
import org.springframework.web.bind.annotation.GetMapping
Expand All @@ -25,26 +24,19 @@ class CheckInController(

@Operation(summary = "세션 출석", description = "세션에 출석합니다. (서버에서 현재 시간을 기준으로 출석 처리)")
@PostMapping
@ApiResponses(
ApiResponse(responseCode = "200", description = "출석 성공"),
ApiResponse(responseCode = "AT0001", description = "출석 시간 이전입니다"),
ApiResponse(responseCode = "AT0002", description = "출석 시간이 지났습니다"),
ApiResponse(responseCode = "AT0003", description = "이미 출석했습니다"),
ApiResponse(responseCode = "AT0004", description = "현재 주차에 해당하는 세션을 찾을 수 없습니다."),
ApiResponse(responseCode = "AT0005", description = "현재 위치 파라미터가 누락되었습니다."),
ApiResponse(responseCode = "AT0006", description = "현재 위치와 세션 장소의 거리가 너무 멉니다."),
)
fun checkInSession(
authentication: Authentication,
@RequestParam("latitude", required = false) latitude: Double?,
@RequestParam("longitude", required = false) longitude: Double?,
) {
checkInSession.execute(
CheckInSession.CheckInSessionInput(
now = LocalDateTime.now(),
memberId = authentication.name,
latitude = latitude,
longitude = longitude,
): AttendanceResponse {
return AttendanceResponse.fromDomain(
checkInSession.execute(
CheckInSession.CheckInSessionInput(
now = LocalDateTime.now(),
memberId = authentication.name,
latitude = latitude,
longitude = longitude,
)
)
)
}
Expand Down

0 comments on commit d375a45

Please sign in to comment.