diff --git a/src/main/kotlin/com/info/maeumgagym/core/routine/port/in/ReadRoutineUseCase.kt b/src/main/kotlin/com/info/maeumgagym/core/routine/port/in/ReadRoutineUseCase.kt index d652715d..ef328ac5 100644 --- a/src/main/kotlin/com/info/maeumgagym/core/routine/port/in/ReadRoutineUseCase.kt +++ b/src/main/kotlin/com/info/maeumgagym/core/routine/port/in/ReadRoutineUseCase.kt @@ -1,7 +1,7 @@ package com.info.maeumgagym.core.routine.port.`in` -import com.info.maeumgagym.core.routine.dto.response.RoutineResponse +import com.info.maeumgagym.core.routine.dto.response.CompletableRoutineResponse interface ReadRoutineUseCase { - fun readFromId(routineId: Long): RoutineResponse + fun readFromId(routineId: Long): CompletableRoutineResponse } diff --git a/src/main/kotlin/com/info/maeumgagym/core/routine/service/ReadRoutineService.kt b/src/main/kotlin/com/info/maeumgagym/core/routine/service/ReadRoutineService.kt index c06d969e..2f2b1a6e 100644 --- a/src/main/kotlin/com/info/maeumgagym/core/routine/service/ReadRoutineService.kt +++ b/src/main/kotlin/com/info/maeumgagym/core/routine/service/ReadRoutineService.kt @@ -4,16 +4,18 @@ import com.info.maeumgagym.common.annotation.responsibility.ReadOnlyUseCase import com.info.maeumgagym.common.exception.BusinessLogicException import com.info.maeumgagym.common.exception.SecurityException import com.info.maeumgagym.core.auth.port.out.ReadCurrentUserPort -import com.info.maeumgagym.core.routine.dto.response.RoutineResponse +import com.info.maeumgagym.core.routine.dto.response.CompletableRoutineResponse import com.info.maeumgagym.core.routine.port.`in`.ReadRoutineUseCase +import com.info.maeumgagym.core.routine.port.out.ExistsRoutineHistoryPort import com.info.maeumgagym.core.routine.port.out.ReadRoutinePort @ReadOnlyUseCase internal class ReadRoutineService( private val readRoutinePort: ReadRoutinePort, + private val existsRoutineHistoryPort: ExistsRoutineHistoryPort, private val readCurrentUserPort: ReadCurrentUserPort ) : ReadRoutineUseCase { - override fun readFromId(routineId: Long): RoutineResponse { + override fun readFromId(routineId: Long): CompletableRoutineResponse { val routine = readRoutinePort.readById(routineId) ?: throw BusinessLogicException.ROUTINE_NOT_FOUND @@ -21,6 +23,8 @@ internal class ReadRoutineService( throw SecurityException.PERMISSION_DENIED } - return routine.toResponse() + return routine.toResponse( + isCompleted = existsRoutineHistoryPort.existByOriginIdToday(routine.id!!) + ) } } diff --git a/src/main/kotlin/com/info/maeumgagym/presentation/controller/routine/RoutineController.kt b/src/main/kotlin/com/info/maeumgagym/presentation/controller/routine/RoutineController.kt index 1149e775..e155e082 100644 --- a/src/main/kotlin/com/info/maeumgagym/presentation/controller/routine/RoutineController.kt +++ b/src/main/kotlin/com/info/maeumgagym/presentation/controller/routine/RoutineController.kt @@ -3,8 +3,8 @@ package com.info.maeumgagym.presentation.controller.routine import com.info.maeumgagym.common.annotation.responsibility.WebAdapter import com.info.maeumgagym.common.annotation.security.RequireAuthentication import com.info.maeumgagym.core.routine.dto.response.CompletableRoutineListResponse +import com.info.maeumgagym.core.routine.dto.response.CompletableRoutineResponse import com.info.maeumgagym.core.routine.dto.response.RoutineHistoryListResponse -import com.info.maeumgagym.core.routine.dto.response.RoutineResponse import com.info.maeumgagym.core.routine.port.`in`.* import com.info.maeumgagym.presentation.common.locationheader.LocationHeaderManager import com.info.maeumgagym.presentation.controller.routine.dto.CreateRoutineWebRequest @@ -100,7 +100,7 @@ private class RoutineController( @Valid @Positive(message = "0보다 커야 합니다.") id: Long - ): RoutineResponse = readRoutineUseCase.readFromId(id) + ): CompletableRoutineResponse = readRoutineUseCase.readFromId(id) @Operation(summary = "루틴 완료 API") @ResponseStatus(HttpStatus.NO_CONTENT)