Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 8
feat: 지원 현황 미리보기 API 추가#815
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
Uh oh!
There was an error while loading. Please reload this page.
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
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9 src/main/java/com/example/solidconnection/application/controller/ApplicationController.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
8 changes: 8 additions & 0 deletions
8 src/main/java/com/example/solidconnection/application/dto/ApplicationPreviewResponse.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,8 @@ | ||
| package com.example.solidconnection.application.dto; | ||
| import java.util.List; | ||
| public record ApplicationPreviewResponse( | ||
| long totalUniversityCount, | ||
| List<ApplicationUniversityPreviewResponse> universities) { | ||
| } |
25 changes: 25 additions & 0 deletions
25 ...ava/com/example/solidconnection/application/dto/ApplicationUniversityPreviewResponse.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,25 @@ | ||
| package com.example.solidconnection.application.dto; | ||
| import com.example.solidconnection.university.domain.UnivApplyInfo; | ||
| public record ApplicationUniversityPreviewResponse( | ||
| long id, | ||
| String koreanName, | ||
| Integer studentCapacity, | ||
| String region, | ||
| String country, | ||
| String logoImageUrl, | ||
| String backgroundImageUrl) { | ||
| public static ApplicationUniversityPreviewResponse from(UnivApplyInfo univApplyInfo) { | ||
| return new ApplicationUniversityPreviewResponse( | ||
| univApplyInfo.getId(), | ||
| univApplyInfo.getKoreanName(), | ||
| univApplyInfo.getStudentCapacity(), | ||
| univApplyInfo.getUniversity().getRegion().getKoreanName(), | ||
| univApplyInfo.getUniversity().getCountry().getKoreanName(), | ||
| univApplyInfo.getUniversity().getLogoImageUrl(), | ||
| univApplyInfo.getUniversity().getBackgroundImageUrl() | ||
| ); | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33 src/main/java/com/example/solidconnection/application/repository/ApplicationRepository.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
23 changes: 23 additions & 0 deletions
23 src/main/java/com/example/solidconnection/application/service/ApplicationQueryService.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 |
|---|---|---|
| @@ -2,11 +2,13 @@ | ||
| import static com.example.solidconnection.common.exception.ErrorCode.APPLICATION_NOT_APPROVED; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.CURRENT_TERM_NOT_FOUND; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.SCHOOL_EMAIL_NOT_VERIFIED; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.USER_NOT_FOUND; | ||
| import com.example.solidconnection.application.domain.Application; | ||
| import com.example.solidconnection.application.domain.ApplicationChoice; | ||
| import com.example.solidconnection.application.dto.ApplicantsResponse; | ||
| import com.example.solidconnection.application.dto.ApplicationPreviewResponse; | ||
| import com.example.solidconnection.application.dto.ApplicationsResponse; | ||
| import com.example.solidconnection.application.repository.ApplicationRepository; | ||
| import com.example.solidconnection.common.VerifyStatus; | ||
| @@ -41,6 +43,27 @@ public class ApplicationQueryService { | ||
| private final TermRepository termRepository; | ||
| private final HomeUniversityRepository homeUniversityRepository; | ||
| @Transactional(readOnly = true) | ||
| public ApplicationPreviewResponse getApplicantUniversityPreviews(long siteUserId) { | ||
| SiteUser siteUser = siteUserRepository.findById(siteUserId) | ||
| .orElseThrow(() -> new CustomException(USER_NOT_FOUND)); | ||
| if (siteUser.getHomeUniversityId() == null) { | ||
| throw new CustomException(SCHOOL_EMAIL_NOT_VERIFIED); | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| Term term = termRepository.findByIsCurrentTrue() | ||
| .orElseThrow(() -> new CustomException(CURRENT_TERM_NOT_FOUND)); | ||
| return new ApplicationPreviewResponse( | ||
| univApplyInfoRepository.countByTermIdAndHomeUniversityId(term.getId(), siteUser.getHomeUniversityId()), | ||
| applicationRepository.findApplicantUniversityPreviews( | ||
| VerifyStatus.APPROVED, | ||
| term.getId(), | ||
| siteUser.getHomeUniversityId()) | ||
| ); | ||
| } | ||
| @Transactional(readOnly = true) | ||
| public ApplicationsResponse getApplicants(long siteUserId, String regionCode, String keyword) { | ||
| SiteUser siteUser = siteUserRepository.findById(siteUserId) | ||
2 changes: 2 additions & 0 deletions
2 src/main/java/com/example/solidconnection/university/repository/UnivApplyInfoRepository.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
121 changes: 121 additions & 0 deletions
121 ...est/java/com/example/solidconnection/application/service/ApplicationQueryServiceTest.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,14 +1,19 @@ | ||
| package com.example.solidconnection.application.service; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.SCHOOL_EMAIL_NOT_VERIFIED; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
| import com.example.solidconnection.application.domain.Application; | ||
| import com.example.solidconnection.application.dto.ApplicantResponse; | ||
| import com.example.solidconnection.application.dto.ApplicantsResponse; | ||
| import com.example.solidconnection.application.dto.ApplicationPreviewResponse; | ||
| import com.example.solidconnection.application.dto.ApplicationUniversityPreviewResponse; | ||
| import com.example.solidconnection.application.dto.ApplicationsResponse; | ||
| import com.example.solidconnection.application.fixture.ApplicationFixture; | ||
| import com.example.solidconnection.application.repository.ApplicationRepository; | ||
| import com.example.solidconnection.common.VerifyStatus; | ||
| import com.example.solidconnection.common.exception.CustomException; | ||
| import com.example.solidconnection.location.region.fixture.RegionFixture; | ||
| import com.example.solidconnection.score.domain.GpaScore; | ||
| import com.example.solidconnection.score.domain.LanguageTestScore; | ||
| @@ -20,7 +25,9 @@ | ||
| import com.example.solidconnection.term.domain.Term; | ||
| import com.example.solidconnection.term.fixture.TermFixture; | ||
| import com.example.solidconnection.university.domain.UnivApplyInfo; | ||
| import com.example.solidconnection.university.fixture.HomeUniversityFixture; | ||
| import com.example.solidconnection.university.fixture.UnivApplyInfoFixture; | ||
| import com.example.solidconnection.university.fixture.UnivApplyInfoFixtureBuilder; | ||
| import java.util.List; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| @@ -47,6 +54,12 @@ class ApplicationQueryServiceTest { | ||
| @Autowired | ||
| private UnivApplyInfoFixture univApplyInfoFixture; | ||
| @Autowired | ||
| private UnivApplyInfoFixtureBuilder univApplyInfoFixtureBuilder; | ||
| @Autowired | ||
| private HomeUniversityFixture homeUniversityFixture; | ||
| @Autowired | ||
| private GpaScoreFixture gpaScoreFixture; | ||
| @@ -98,6 +111,114 @@ void setUp() { | ||
| 서던덴마크대학교_지원_정보 = univApplyInfoFixture.서던덴마크대학교_지원_정보(term.getId()); | ||
| } | ||
| @Nested | ||
Hexeong marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| @DisplayName("지원 현황 미리보기 조회") | ||
| class 지원_현황_미리보기_조회_테스트 { | ||
| @Test | ||
| void 자신의_모교에_속한_지원_대학만_중복_없이_조회한다() { | ||
| // given | ||
| SiteUser inhaUniversityUser = siteUserFixture.국내_대학_정보_소지_사용자( | ||
| 괌대학_A_지원_정보.getHomeUniversity().getId()); | ||
| applicationFixture.지원서( | ||
| user1, "nickname1", term.getId(), | ||
| gpaScore1.getGpa(), languageTestScore1.getLanguageTest(), | ||
| List.of(괌대학_A_지원_정보.getId(), 버지니아공과대학_지원_정보.getId()) | ||
| ); | ||
| applicationFixture.지원서( | ||
| user2, "nickname2", term.getId(), | ||
| gpaScore2.getGpa(), languageTestScore2.getLanguageTest(), | ||
| List.of(괌대학_A_지원_정보.getId()) | ||
| ); | ||
| UnivApplyInfo 인천대학교_전용_지원_정보 = univApplyInfoFixtureBuilder.univApplyInfo() | ||
| .termId(term.getId()) | ||
| .koreanName("인천대학교 전용 교환 대학") | ||
| .university(서던덴마크대학교_지원_정보.getUniversity()) | ||
| .homeUniversity(homeUniversityFixture.인천대학교()) | ||
| .create(); | ||
| applicationFixture.지원서( | ||
| user3, "nickname3", term.getId(), | ||
| gpaScore3.getGpa(), languageTestScore3.getLanguageTest(), | ||
| List.of(인천대학교_전용_지원_정보.getId()) | ||
| ); | ||
| Application deletedApplication = applicationFixture.지원서( | ||
| user3, "nickname3", term.getId(), | ||
| gpaScore3.getGpa(), languageTestScore3.getLanguageTest(), | ||
| List.of(서던덴마크대학교_지원_정보.getId()) | ||
| ); | ||
| deletedApplication.setIsDeleteTrue(); | ||
| applicationRepository.save(deletedApplication); | ||
| UnivApplyInfo 승인_대기_지원_정보 = univApplyInfoFixtureBuilder.univApplyInfo() | ||
| .termId(term.getId()) | ||
| .koreanName("승인 대기 교환 대학") | ||
| .university(서던덴마크대학교_지원_정보.getUniversity()) | ||
| .homeUniversity(괌대학_A_지원_정보.getHomeUniversity()) | ||
| .create(); | ||
| Application pendingApplication = applicationFixture.지원서( | ||
| user1, "pending-nickname", term.getId(), | ||
| gpaScore1.getGpa(), languageTestScore1.getLanguageTest(), | ||
| List.of(승인_대기_지원_정보.getId()) | ||
| ); | ||
| pendingApplication.setVerifyStatus(VerifyStatus.PENDING); | ||
| applicationRepository.save(pendingApplication); | ||
| UnivApplyInfo 승인_거절_지원_정보 = univApplyInfoFixtureBuilder.univApplyInfo() | ||
| .termId(term.getId()) | ||
| .koreanName("승인 거절 교환 대학") | ||
| .university(서던덴마크대학교_지원_정보.getUniversity()) | ||
| .homeUniversity(괌대학_A_지원_정보.getHomeUniversity()) | ||
| .create(); | ||
| Application rejectedApplication = applicationFixture.지원서( | ||
| user2, "rejected-nickname", term.getId(), | ||
| gpaScore2.getGpa(), languageTestScore2.getLanguageTest(), | ||
| List.of(승인_거절_지원_정보.getId()) | ||
| ); | ||
| rejectedApplication.setVerifyStatus(VerifyStatus.REJECTED); | ||
| applicationRepository.save(rejectedApplication); | ||
| // when | ||
| ApplicationPreviewResponse response = applicationQueryService.getApplicantUniversityPreviews( | ||
| inhaUniversityUser.getId()); | ||
| // then | ||
| assertThat(response.totalUniversityCount()).isEqualTo(5); | ||
| assertThat(response.universities()).containsExactly( | ||
| ApplicationUniversityPreviewResponse.from(괌대학_A_지원_정보), | ||
| ApplicationUniversityPreviewResponse.from(버지니아공과대학_지원_정보) | ||
| ); | ||
| } | ||
| @Test | ||
| void 성적과_지원서를_제출하지_않은_로그인_사용자도_미리보기를_조회할_수_있다() { | ||
| // given | ||
| SiteUser signedInUserWithoutScores = siteUserFixture.국내_대학_정보_소지_사용자( | ||
| 괌대학_A_지원_정보.getHomeUniversity().getId()); | ||
| applicationFixture.지원서( | ||
| user2, "nickname2", term.getId(), | ||
| gpaScore2.getGpa(), languageTestScore2.getLanguageTest(), | ||
| List.of(괌대학_A_지원_정보.getId()) | ||
| ); | ||
| // when | ||
| ApplicationPreviewResponse response = applicationQueryService.getApplicantUniversityPreviews( | ||
| signedInUserWithoutScores.getId()); | ||
| // then | ||
| assertThat(response.totalUniversityCount()).isEqualTo(3); | ||
| assertThat(response.universities()).containsExactly( | ||
| ApplicationUniversityPreviewResponse.from(괌대학_A_지원_정보) | ||
| ); | ||
| } | ||
| @Test | ||
| void 모교가_등록되지_않은_사용자는_미리보기를_조회할_수_없다() { | ||
| // when | ||
| // then | ||
| assertThatThrownBy(() -> applicationQueryService.getApplicantUniversityPreviews(user1.getId())) | ||
| .isInstanceOf(CustomException.class) | ||
| .hasMessage(SCHOOL_EMAIL_NOT_VERIFIED.getMessage()); | ||
| } | ||
| } | ||
| @Nested | ||
| class 지원자_목록_조회_테스트 { | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.