Skip to content

Commit 3222f40

Browse files
authored
Merge pull request #61 from EntryDSM/feature/60-query-user-status-api
Feature/60 query user status api
2 parents af45aa3 + f4e66d5 commit 3222f40

7 files changed

Lines changed: 128 additions & 2 deletions

File tree

casper-application-domain/src/main/kotlin/hs/kr/entrydsm/domain/status/aggregates/Status.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ data class Status(
3232
val isSubmitted: Boolean
3333
get() = applicationStatus != ApplicationStatus.NOT_APPLIED &&
3434
applicationStatus != ApplicationStatus.WRITING
35+
36+
val isPrintsArrived: Boolean
37+
get() = applicationStatus != ApplicationStatus.NOT_APPLIED &&
38+
applicationStatus != ApplicationStatus.WRITING &&
39+
applicationStatus != ApplicationStatus.SUBMITTED &&
40+
applicationStatus != ApplicationStatus.WAITING_DOCUMENTS
3541
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package hs.kr.entrydsm.application.domain.application.presentation
2+
3+
import hs.kr.entrydsm.application.domain.application.presentation.dto.response.GetApplicationStatusResponse
4+
import hs.kr.entrydsm.application.domain.application.usecase.GetMyApplicationStatusUseCase
5+
import hs.kr.entrydsm.application.global.document.application.WebApplicationApiDocument
6+
import org.springframework.web.bind.annotation.GetMapping
7+
import org.springframework.web.bind.annotation.RequestMapping
8+
import org.springframework.web.bind.annotation.RestController
9+
10+
@RestController
11+
@RequestMapping("/application")
12+
class WebApplicationAdapter(
13+
private val getMyApplicationStatusUseCase: GetMyApplicationStatusUseCase,
14+
) : WebApplicationApiDocument {
15+
16+
@GetMapping("/status")
17+
override fun getMyApplicationStatus(): GetApplicationStatusResponse = getMyApplicationStatusUseCase.execute()
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package hs.kr.entrydsm.application.domain.application.presentation.dto.response
2+
3+
data class GetApplicationStatusResponse(
4+
val receiptCode: Long,
5+
val phoneNumber: String?,
6+
val name: String?,
7+
val isSubmitted: Boolean,
8+
val isPrintedArrived: Boolean,
9+
val selfIntroduce: String?,
10+
val studyPlan: String?
11+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package hs.kr.entrydsm.application.domain.application.usecase
2+
3+
import hs.kr.entrydsm.application.domain.application.exception.ApplicationNotFoundException
4+
import hs.kr.entrydsm.application.domain.application.presentation.dto.response.GetApplicationStatusResponse
5+
import hs.kr.entrydsm.application.global.annotation.usecase.ReadOnlyUseCase
6+
import hs.kr.entrydsm.application.global.security.SecurityAdapter
7+
import hs.kr.entrydsm.domain.application.interfaces.ApplicationContract
8+
import hs.kr.entrydsm.domain.status.exception.StatusExceptions
9+
import hs.kr.entrydsm.domain.status.interfaces.StatusContract
10+
import hs.kr.entrydsm.domain.user.interfaces.UserContract
11+
12+
@ReadOnlyUseCase
13+
class GetMyApplicationStatusUseCase(
14+
private val securityAdapter: SecurityAdapter,
15+
private val applicationContract: ApplicationContract,
16+
private val userContract: UserContract,
17+
private val statusContract: StatusContract
18+
) {
19+
fun execute(): GetApplicationStatusResponse {
20+
val userId = securityAdapter.getCurrentUserId()
21+
22+
val application = applicationContract.getApplicationByUserId(userId)
23+
?: throw ApplicationNotFoundException()
24+
25+
val status = statusContract.queryStatusByReceiptCode(application.receiptCode)
26+
?: throw StatusExceptions.StatusNotFoundException()
27+
28+
val user = userContract.queryUserByUserId(userId)
29+
30+
val phoneNumber = if (user.isParent) application.parentTel else application.applicantTel
31+
val name = if ( user.isParent && application.applicantName == null)
32+
application.parentName else application.applicantName
33+
34+
return GetApplicationStatusResponse(
35+
receiptCode = application.receiptCode,
36+
phoneNumber = phoneNumber,
37+
name = name,
38+
isSubmitted = status.isSubmitted,
39+
isPrintedArrived = status.isPrintsArrived,
40+
selfIntroduce = application.selfIntroduce,
41+
studyPlan = application.studyPlan
42+
)
43+
}
44+
}

casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/config/SecurityConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SecurityConfig(
5959
.requestMatchers("/api/v1/applications/**").hasRole(UserRole.USER.name)
6060
.requestMatchers("/photo").hasRole(UserRole.USER.name)
6161
.requestMatchers("/pass/**").hasRole(UserRole.USER.name)
62+
.requestMatchers("/application/**").hasRole(UserRole.USER.name)
6263
.anyRequest().authenticated()
6364
}
6465
.with(filterConfig) { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package hs.kr.entrydsm.application.global.document.application
2+
3+
import hs.kr.entrydsm.application.domain.application.presentation.dto.response.GetApplicationStatusResponse
4+
import io.swagger.v3.oas.annotations.Operation
5+
import io.swagger.v3.oas.annotations.media.Content
6+
import io.swagger.v3.oas.annotations.media.Schema
7+
import io.swagger.v3.oas.annotations.responses.ApiResponse
8+
import io.swagger.v3.oas.annotations.responses.ApiResponses
9+
import io.swagger.v3.oas.annotations.tags.Tag
10+
11+
@Tag(name = "Application", description = "Application API")
12+
interface WebApplicationApiDocument {
13+
14+
@Operation(
15+
summary = "지원정보 상태 조회",
16+
description = "현재 로그인한 사용자의 지원정보 상태를 조회합니다.",
17+
)
18+
@ApiResponses(
19+
value = [
20+
ApiResponse(
21+
responseCode = "200",
22+
description = "지원정보 상태 조회 성공",
23+
content = [Content(schema = Schema(implementation = GetApplicationStatusResponse::class))]
24+
),
25+
ApiResponse(
26+
responseCode = "403",
27+
description = "인증되지 않은 사용자",
28+
content = [Content(schema = Schema(hidden = true))],
29+
),
30+
ApiResponse(
31+
responseCode = "404",
32+
description = "원서 또는 지원자 상태 정보를 찾을 수 없음",
33+
content = [Content(schema = Schema(hidden = true))],
34+
),
35+
]
36+
)
37+
fun getMyApplicationStatus(): GetApplicationStatusResponse
38+
}

casper-application-infrastructure/src/main/kotlin/hs/kr/entrydsm/application/global/document/pass/PassApiDocument.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ interface PassApiDocument {
2222
description = "합격 여부 조회 성공",
2323
content = [Content(schema = Schema(implementation = QueryIsFirstRoundPassResponse::class))]
2424
),
25-
ApiResponse(responseCode = "403", description = "인증되지 않은 사용자"),
26-
ApiResponse(responseCode = "404", description = "지원자 또는 전형 정보를 찾을 수 없음"),
25+
ApiResponse(
26+
responseCode = "403",
27+
description = "인증되지 않은 사용자",
28+
content = [Content(schema = Schema(hidden = true))],
29+
),
30+
ApiResponse(
31+
responseCode = "404",
32+
description = "지원자 또는 전형 정보를 찾을 수 없음",
33+
content = [Content(schema = Schema(hidden = true))],
34+
),
2735
]
2836
)
2937
suspend fun queryIsFirstRound(): QueryIsFirstRoundPassResponse

0 commit comments

Comments
 (0)