Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -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()
}
Original file line number Diff line number Diff line change
@@ -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?
)
Original file line number Diff line number Diff line change
@@ -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
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading