diff --git a/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/status/aggregates/Status.kt b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/status/aggregates/Status.kt index 2432fe97..0a9075d6 100644 --- a/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/status/aggregates/Status.kt +++ b/casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/status/aggregates/Status.kt @@ -32,4 +32,10 @@ data class Status( val isSubmitted: Boolean get() = applicationStatus != ApplicationStatus.NOT_APPLIED && applicationStatus != ApplicationStatus.WRITING + + val isPrintsArrived: Boolean + get() = applicationStatus != ApplicationStatus.NOT_APPLIED && + applicationStatus != ApplicationStatus.WRITING && + applicationStatus != ApplicationStatus.SUBMITTED && + applicationStatus != ApplicationStatus.WAITING_DOCUMENTS } diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/WebApplicationAdapter.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/WebApplicationAdapter.kt new file mode 100644 index 00000000..0beb5e81 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/WebApplicationAdapter.kt @@ -0,0 +1,18 @@ +package hs.kr.entrydsm.application.domain.application.presentation + +import hs.kr.entrydsm.application.domain.application.presentation.dto.response.GetApplicationStatusResponse +import hs.kr.entrydsm.application.domain.application.usecase.GetMyApplicationStatusUseCase +import hs.kr.entrydsm.application.global.document.application.WebApplicationApiDocument +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/application") +class WebApplicationAdapter( + private val getMyApplicationStatusUseCase: GetMyApplicationStatusUseCase, +) : WebApplicationApiDocument { + + @GetMapping("/status") + override fun getMyApplicationStatus(): GetApplicationStatusResponse = getMyApplicationStatusUseCase.execute() +} \ No newline at end of file diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/dto/response/GetApplicationStatusResponse.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/dto/response/GetApplicationStatusResponse.kt new file mode 100644 index 00000000..446c77b3 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/presentation/dto/response/GetApplicationStatusResponse.kt @@ -0,0 +1,11 @@ +package hs.kr.entrydsm.application.domain.application.presentation.dto.response + +data class GetApplicationStatusResponse( + val receiptCode: Long, + val phoneNumber: String?, + val name: String?, + val isSubmitted: Boolean, + val isPrintedArrived: Boolean, + val selfIntroduce: String?, + val studyPlan: String? +) diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/GetMyApplicationStatusUseCase.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/GetMyApplicationStatusUseCase.kt new file mode 100644 index 00000000..778d9543 --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/domain/application/usecase/GetMyApplicationStatusUseCase.kt @@ -0,0 +1,44 @@ +package hs.kr.entrydsm.application.domain.application.usecase + +import hs.kr.entrydsm.application.domain.application.exception.ApplicationNotFoundException +import hs.kr.entrydsm.application.domain.application.presentation.dto.response.GetApplicationStatusResponse +import hs.kr.entrydsm.application.global.annotation.usecase.ReadOnlyUseCase +import hs.kr.entrydsm.application.global.security.SecurityAdapter +import hs.kr.entrydsm.domain.application.interfaces.ApplicationContract +import hs.kr.entrydsm.domain.status.exception.StatusExceptions +import hs.kr.entrydsm.domain.status.interfaces.StatusContract +import hs.kr.entrydsm.domain.user.interfaces.UserContract + +@ReadOnlyUseCase +class GetMyApplicationStatusUseCase( + private val securityAdapter: SecurityAdapter, + private val applicationContract: ApplicationContract, + private val userContract: UserContract, + private val statusContract: StatusContract +) { + fun execute(): GetApplicationStatusResponse { + val userId = securityAdapter.getCurrentUserId() + + val application = applicationContract.getApplicationByUserId(userId) + ?: throw ApplicationNotFoundException() + + val status = statusContract.queryStatusByReceiptCode(application.receiptCode) + ?: throw StatusExceptions.StatusNotFoundException() + + val user = userContract.queryUserByUserId(userId) + + val phoneNumber = if (user.isParent) application.parentTel else application.applicantTel + val name = if ( user.isParent && application.applicantName == null) + application.parentName else application.applicantName + + return GetApplicationStatusResponse( + receiptCode = application.receiptCode, + phoneNumber = phoneNumber, + name = name, + isSubmitted = status.isSubmitted, + isPrintedArrived = status.isPrintsArrived, + selfIntroduce = application.selfIntroduce, + studyPlan = application.studyPlan + ) + } +} \ No newline at end of file diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt index fb45c7bc..4ca1048e 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt @@ -59,6 +59,7 @@ class SecurityConfig( .requestMatchers("/api/v1/applications/**").hasRole(UserRole.USER.name) .requestMatchers("/photo").hasRole(UserRole.USER.name) .requestMatchers("/pass/**").hasRole(UserRole.USER.name) + .requestMatchers("/application/**").hasRole(UserRole.USER.name) .anyRequest().authenticated() } .with(filterConfig) { } diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/document/application/WebApplicationApiDocument.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/document/application/WebApplicationApiDocument.kt new file mode 100644 index 00000000..debd8e1c --- /dev/null +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/document/application/WebApplicationApiDocument.kt @@ -0,0 +1,38 @@ +package hs.kr.entrydsm.application.global.document.application + +import hs.kr.entrydsm.application.domain.application.presentation.dto.response.GetApplicationStatusResponse +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.media.Content +import io.swagger.v3.oas.annotations.media.Schema +import io.swagger.v3.oas.annotations.responses.ApiResponse +import io.swagger.v3.oas.annotations.responses.ApiResponses +import io.swagger.v3.oas.annotations.tags.Tag + +@Tag(name = "Application", description = "Application API") +interface WebApplicationApiDocument { + + @Operation( + summary = "지원정보 상태 조회", + description = "현재 로그인한 사용자의 지원정보 상태를 조회합니다.", + ) + @ApiResponses( + value = [ + ApiResponse( + responseCode = "200", + description = "지원정보 상태 조회 성공", + content = [Content(schema = Schema(implementation = GetApplicationStatusResponse::class))] + ), + ApiResponse( + responseCode = "403", + description = "인증되지 않은 사용자", + content = [Content(schema = Schema(hidden = true))], + ), + ApiResponse( + responseCode = "404", + description = "원서 또는 지원자 상태 정보를 찾을 수 없음", + content = [Content(schema = Schema(hidden = true))], + ), + ] + ) + fun getMyApplicationStatus(): GetApplicationStatusResponse +} \ No newline at end of file diff --git a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/document/pass/PassApiDocument.kt b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/document/pass/PassApiDocument.kt index 3545fb20..2a94d33c 100644 --- a/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/document/pass/PassApiDocument.kt +++ b/casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/document/pass/PassApiDocument.kt @@ -22,8 +22,16 @@ interface PassApiDocument { description = "합격 여부 조회 성공", content = [Content(schema = Schema(implementation = QueryIsFirstRoundPassResponse::class))] ), - ApiResponse(responseCode = "403", description = "인증되지 않은 사용자"), - ApiResponse(responseCode = "404", description = "지원자 또는 전형 정보를 찾을 수 없음"), + ApiResponse( + responseCode = "403", + description = "인증되지 않은 사용자", + content = [Content(schema = Schema(hidden = true))], + ), + ApiResponse( + responseCode = "404", + description = "지원자 또는 전형 정보를 찾을 수 없음", + content = [Content(schema = Schema(hidden = true))], + ), ] ) suspend fun queryIsFirstRound(): QueryIsFirstRoundPassResponse