-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: 모의지원 시 지원한 대학 정보 응답 추가 #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Gyuhyeok99
merged 3 commits into
solid-connection:develop
from
Gyuhyeok99:refactor/531-add-university-info
Nov 3, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
14 changes: 11 additions & 3 deletions
14
src/main/java/com/example/solidconnection/application/dto/ApplicationSubmissionResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,20 @@ | ||
| package com.example.solidconnection.application.dto; | ||
|
|
||
| import com.example.solidconnection.application.domain.Application; | ||
| import com.example.solidconnection.university.domain.UnivApplyInfo; | ||
| import java.util.List; | ||
|
|
||
| public record ApplicationSubmissionResponse( | ||
| int applyCount | ||
| int totalApplyCount, | ||
| int applyCount, | ||
| UnivApplyInfoResponse appliedUniversities | ||
| ) { | ||
|
|
||
| public static ApplicationSubmissionResponse from(Application application) { | ||
| return new ApplicationSubmissionResponse(application.getUpdateCount()); | ||
| public static ApplicationSubmissionResponse of(int totalApplyCount, Application application, List<UnivApplyInfo> uniApplyInfos) { | ||
| return new ApplicationSubmissionResponse( | ||
| totalApplyCount, | ||
| application.getUpdateCount(), | ||
| UnivApplyInfoResponse.of(application, uniApplyInfos) | ||
| ); | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/example/solidconnection/application/dto/UnivApplyInfoResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package com.example.solidconnection.application.dto; | ||
|
|
||
| import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; | ||
|
|
||
| import com.example.solidconnection.application.domain.Application; | ||
| import com.example.solidconnection.university.domain.UnivApplyInfo; | ||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| public record UnivApplyInfoResponse( | ||
|
|
||
| @JsonProperty("firstChoiceUniversity") | ||
| String firstChoiceUnivApplyInfo, | ||
|
|
||
| @JsonProperty("secondChoiceUniversity") | ||
| @JsonInclude(NON_NULL) | ||
| String secondChoiceUnivApplyInfo, | ||
|
|
||
| @JsonProperty("thirdChoiceUniversity") | ||
| @JsonInclude(NON_NULL) | ||
| String thirdChoiceUnivApplyInfo) { | ||
|
|
||
| public static UnivApplyInfoResponse of(Application application, List<UnivApplyInfo> univApplyInfos) { | ||
| Map<Long, String> univApplyInfoMap = univApplyInfos.stream() | ||
| .collect(Collectors.toMap( | ||
| UnivApplyInfo::getId, | ||
| UnivApplyInfo::getKoreanName | ||
| )); | ||
|
|
||
| return new UnivApplyInfoResponse( | ||
| univApplyInfoMap.get(application.getFirstChoiceUnivApplyInfoId()), | ||
| application.getSecondChoiceUnivApplyInfoId() != null | ||
| ? univApplyInfoMap.get(application.getSecondChoiceUnivApplyInfoId()) : null, | ||
| application.getThirdChoiceUnivApplyInfoId() != null | ||
| ? univApplyInfoMap.get(application.getThirdChoiceUnivApplyInfoId()) : null | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
필수 대학 정보 누락 시 즉시 검증 필요
findAllByIds가 전달한 ID를 모두 돌려주지 못하면 firstChoiceUnivApplyInfoId가 map에 존재하지 않아 응답의 firstChoiceUniversity가 null로 직행합니다. 이번 변경으로 해당 필드는 클라이언트에 반드시 내려가야 하는 값인데, 관리자 삭제·동시성 등 현실적인 상황에서 바로 계약이 깨지고 프런트는 NPE나 렌더링 오류를 겪게 됩니다. 저장 전·후 중 한 곳에서라도 조회 결과에 firstChoiceUnivApplyInfoId가 포함돼 있는지 확인하고, 누락 시 CustomException으로 즉시 중단해 주세요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ coderabbitai
firstChoiceUnivApplyInfoId 이값은 무조건 존재한다는 가정인데 검증해야해?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 3379
🏁 Script executed:
Length of output: 36426
@Gyuhyeok99
네, 요청 단계에서는
ValidUnivApplyInfoChoiceValidator가 firstChoiceUnivApplyInfoId의 null 여부를 검증하고 있습니다.하지만 제가 우려한 부분은 조금 다른 시나리오입니다:
현재 상황:
Application저장 ✅findAllByIds로 UnivApplyInfo 조회get(123L)=nullnull→ API 응답에서 필수 필드가 null기술적 격차:
Long필드로만 저장 (외래키 제약 없음)@JsonInclude(NON_NULL)없이 필수 응답 필드선택지:
@ManyToOne관계 추가해 DB 레벨 보장어떤 방향이 좋을까요? 프로덕션 환경에서 관리자 실수나 데이터 정합성 이슈를 고려하면 1번이나 2번이 안전하지만, 오버헤드를 고려하면 3번도 선택지입니다.
🧬 Code Graph Analysis Results
[UnivApplyInfoQueryService.java:16-55]
[ApplicationQueryService.java:30-136]
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 분들 의견 듣고 판단하겠습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gyuhyeok99 네, 좋습니다! 팀 논의 후 결정하시면 됩니다. 추가로 도움이 필요하시면 언제든 말씀해 주세요. 😊
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 해당 id는 무조건 존재하는 상황에서 요청이 온다 생각하기 때문에 추가적인 검증이 필요하지 않다고 생각이 듭니다.
그러나 혹시라도 매우 낮은 확률로 서비스 운영 중에 db 데이터가 잘못되었거나(예: 다른 작업중 db 오류 및 요청 중 해당 학교가 교환 학생 지원이 유효하지 않은 상태가 되어 db에 반영했을 때 -- 사실 그럴일이 없을 것 같긴 합니다.) 지원 자체가 안되는 상황을 유도하기 위해 검증하는 것도 좋다고 생각이 듭니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
대학 ID의 경우, 사용자가 직접 값을 입력하는 변수는 아니다 보니 저도 해당 검증은 오버헤드라는 생각이 드네요! 방어적 프로그래밍 관점에서도 대학 ID는 사용자에 의해 값이 관리되지 않기 때문에 저는 굳이라는 생각이 듭니다~