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 @@ -14,6 +14,7 @@
import com.example.solidconnection.university.domain.UnivApplyInfo;
import com.example.solidconnection.university.repository.UnivApplyInfoRepository;
import com.example.solidconnection.university.repository.custom.UnivApplyInfoFilterRepositoryImpl;
import io.micrometer.common.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -45,7 +46,8 @@ public ApplicationsResponse getApplicants(long siteUserId, String regionCode, St
// 1. 대학 지원 정보 필터링 (regionCode, keyword)
SiteUser siteUser = siteUserRepository.findById(siteUserId)
.orElseThrow(() -> new CustomException(USER_NOT_FOUND));
List<UnivApplyInfo> univApplyInfos = universityFilterRepository.findAllByRegionCodeAndKeywords(regionCode, List.of(keyword));
List<String> keywords = StringUtils.isNotBlank(keyword) ? List.of(keyword) : List.of();
List<UnivApplyInfo> univApplyInfos = universityFilterRepository.findAllByRegionCodeAndKeywordsAndTerm(regionCode, keywords, term);
if (univApplyInfos.isEmpty()) {
return new ApplicationsResponse(List.of(), List.of(), List.of());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public interface UnivApplyInfoFilterRepository {

List<UnivApplyInfo> findAllByRegionCodeAndKeywords(String regionCode, List<String> keywords);
List<UnivApplyInfo> findAllByRegionCodeAndKeywordsAndTerm(String regionCode, List<String> keywords, String term);

List<UnivApplyInfo> findAllByFilter(LanguageTestType testType, String testScore, String term, List<String> countryKoreanNames);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public UnivApplyInfoFilterRepositoryImpl(EntityManager em) {
}

@Override
public List<UnivApplyInfo> findAllByRegionCodeAndKeywords(String regionCode, List<String> keywords) {
public List<UnivApplyInfo> findAllByRegionCodeAndKeywordsAndTerm(String regionCode, List<String> keywords, String term) {
QUnivApplyInfo univApplyInfo = QUnivApplyInfo.univApplyInfo;
QUniversity university = QUniversity.university;
QCountry country = QCountry.country;
Expand All @@ -45,6 +45,7 @@ public List<UnivApplyInfo> findAllByRegionCodeAndKeywords(String regionCode, Lis
.where(
regionCodeEq(country, regionCode)
.and(countryOrUniversityContainsKeyword(country, university, keywords))
.and(univApplyInfo.term.eq(term))
)
Comment on lines 46 to 49
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

term null 처리 누락으로 즉시 예외 위험!
term 값이 null이면 Querydsl이 "eq(null) is not allowed" 예외를 곧장 던져서 /application 조회가 바로 깨집니다. 기존 인터페이스에는 term이 없었기 때문에 호출부에서 관성적으로 null을 넣을 여지가 있고, 설정 누락 시에도 즉시 장애가 나니 사전에 가드가 필요해요. 간단하게 null을 검증한 뒤 쿼리를 빌드하도록 바꿔 주세요.

@@
-        return queryFactory
+        if (term == null) {
+            throw new IllegalArgumentException("term must not be null");
+        }
+
+        return queryFactory
                 .selectFrom(univApplyInfo)
@@
-                                .and(univApplyInfo.term.eq(term))
+                                .and(univApplyInfo.term.eq(term))
🤖 Prompt for AI Agents
In
src/main/java/com/example/solidconnection/university/repository/custom/UnivApplyInfoFilterRepositoryImpl.java
around lines 46 to 49, the code calls univApplyInfo.term.eq(term) without
guarding term which causes Querydsl to throw "eq(null) is not allowed" when term
is null; change the query construction to only add the term predicate when term
is non-null (e.g., create a termEq(term) helper that returns the predicate when
term!=null or null otherwise, or conditionally chain the .and(...) only if term
!= null) so the query builder never calls eq(null).

.distinct()
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ class 지원자_목록_조회_테스트 {
}

@Test
void 이전_학기_지원자는_조회되지_않는다() {
void 현재_학기_지원서만_조회되고_이전_학기_지원서는_제외된다() {
// given
Application application = applicationFixture.지원서(
applicationFixture.지원서(
user1,
"nickname1",
"nickname1_past",
"1988-1",
gpaScore1.getGpa(),
languageTestScore1.getLanguageTest(),
Expand All @@ -262,6 +262,17 @@ class 지원자_목록_조회_테스트 {
null
);

Application currentApplication = applicationFixture.지원서(
user1,
"nickname1",
term,
gpaScore1.getGpa(),
languageTestScore1.getLanguageTest(),
괌대학_A_지원_정보.getId(),
null,
null
);

// when
ApplicationsResponse response = applicationQueryService.getApplicants(
user1.getId(),
Expand All @@ -270,10 +281,11 @@ class 지원자_목록_조회_테스트 {
);

// then
assertThat(response.firstChoice()).doesNotContainAnyElementsOf(List.of(
ApplicantsResponse.of(괌대학_A_지원_정보,
List.of(application), user1)
));
assertThat(response.firstChoice()).containsExactlyInAnyOrder(
ApplicantsResponse.of(괌대학_A_지원_정보, List.of(currentApplication), user1),
ApplicantsResponse.of(괌대학_B_지원_정보, List.of(), user1),
ApplicantsResponse.of(서던덴마크대학교_지원_정보, List.of(), user1)
);
}

@Test
Expand Down
Loading