33import io .swagger .v3 .oas .annotations .media .Schema ;
44import kgu .developers .domain .graduationUser .domain .GraduationType ;
55import kgu .developers .domain .graduationUser .domain .GraduationUser ;
6+ import kgu .developers .domain .schedule .domain .Schedule ;
7+ import kgu .developers .domain .schedule .domain .SubmissionType ;
68import lombok .Builder ;
79
10+ import java .time .LocalDateTime ;
11+ import java .time .format .DateTimeFormatter ;
12+
813@ Builder
914public record MyGraduationUserResponse (
10- @ Schema (description = "현재 상태" , example = "GRADUATION_TYPE_NOT_SUBMITTED" )
11- GraduationUserStatus status
15+ @ Schema (description = "제목" , example = "최종 보고서를 제출하지 않았어요." )
16+ String title ,
17+
18+ @ Schema (description = "내용" , example = "최종 보고서 마감 기한은 2025년 10월 30일이에요." )
19+ String description
1220) {
13- public static MyGraduationUserResponse from (GraduationUser graduationUser ) {
21+ private static final DateTimeFormatter KOREAN_DATE = DateTimeFormatter .ofPattern ("yyyy년 M월 d일" );
22+
23+
24+ public static MyGraduationUserResponse from (GraduationUser graduationUser , Schedule schedule ) {
25+ GraduationUserStatus status = determineStatus (graduationUser );
26+
27+ String title = switch (status ) {
28+ case GRADUATION_TYPE_NOT_SUBMITTED -> "졸업 유형을 아직 선택하지 않았어요." ;
29+ case PROFESSOR_NOT_ASSIGNED -> "지도교수가 아직 배정되지 않았어요." ;
30+ case MID_THESIS_NOT_SUBMITTED -> "중간 논문을 제출하지 않았어요." ;
31+ case FINAL_THESIS_NOT_SUBMITTED -> "최종 논문을 제출하지 않았어요." ;
32+ case CERTIFICATE_NOT_SUBMITTED -> "자격증을 제출하지 않았어요." ;
33+ case GRADUATION_REQUIREMENTS_MET -> "졸업 요건을 충족했어요." ;
34+ };
35+
36+ String description = switch (status ) {
37+ case MID_THESIS_NOT_SUBMITTED -> deadlineMessage ("중간 논문" , schedule );
38+ case FINAL_THESIS_NOT_SUBMITTED -> deadlineMessage ("최종 논문" , schedule );
39+ case CERTIFICATE_NOT_SUBMITTED -> deadlineMessage ("자격증" , schedule );
40+
41+ case GRADUATION_TYPE_NOT_SUBMITTED ->
42+ "졸업 유형(논문/자격증)을 먼저 선택해주세요." ;
43+ case PROFESSOR_NOT_ASSIGNED ->
44+ "지도교수 배정을 완료해야 다음 절차를 진행할 수 있어요." ;
45+ case GRADUATION_REQUIREMENTS_MET ->
46+ "현재 기준으로 필요한 졸업 요건이 모두 완료되었어요." ;
47+ };
48+
1449 return MyGraduationUserResponse .builder ()
15- .status (determineStatus (graduationUser ))
16- .build ();
50+ .title (title )
51+ .description (description )
52+ .build ();
53+ }
54+
55+ /**
56+ * 서비스에서 schedule 조회할 때 쓰라고 status -> SubmissionType 매핑도 제공
57+ */
58+ public static SubmissionType requiredSubmissionType (GraduationUser graduationUser ) {
59+ GraduationUserStatus status = determineStatus (graduationUser );
60+
61+ return switch (status ) {
62+ case MID_THESIS_NOT_SUBMITTED -> SubmissionType .MIDTHESIS ;
63+ case FINAL_THESIS_NOT_SUBMITTED -> SubmissionType .FINALTHESIS ;
64+ case CERTIFICATE_NOT_SUBMITTED -> SubmissionType .CERTIFICATE ;
65+ default -> null ; // schedule 필요 없는 상태들
66+ };
67+ }
68+
69+ private static String deadlineMessage (String target , Schedule schedule ) {
70+ LocalDateTime endDate = (schedule == null ) ? null : schedule .getEndDate ();
71+ String formatted = (endDate == null ) ? "미정" : endDate .format (KOREAN_DATE );
72+ return target + " 마감 기한은 " + formatted + "이에요." ;
1773 }
1874
1975 private static GraduationUserStatus determineStatus (GraduationUser graduationUser ) {
@@ -32,8 +88,7 @@ private static GraduationUserStatus determineStatus(GraduationUser graduationUse
3288 if (graduationUser .getFinalThesisId () == null ) {
3389 return GraduationUserStatus .FINAL_THESIS_NOT_SUBMITTED ;
3490 }
35- }
36- else if (graduationUser .getGraduationType () == GraduationType .CERTIFICATE ) {
91+ } else if (graduationUser .getGraduationType () == GraduationType .CERTIFICATE ) {
3792 if (graduationUser .getCertificateId () == null ) {
3893 return GraduationUserStatus .CERTIFICATE_NOT_SUBMITTED ;
3994 }
0 commit comments