-
Notifications
You must be signed in to change notification settings - Fork 8
[DEPLOY] 260620 #781
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
[DEPLOY] 260620 #781
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import com.example.solidconnection.university.domain.SemesterAvailableForDispatch; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public record AdminUnivApplyInfoCreateRequest( | ||
| @NotNull Long termId, | ||
| @NotNull Long homeUniversityId, | ||
| @NotNull Long hostUniversityId, | ||
| Integer studentCapacity, | ||
| SemesterAvailableForDispatch semesterAvailableForDispatch, | ||
| String semesterRequirement, | ||
| String detailsForLanguage, | ||
| String gpaRequirement, | ||
| String gpaRequirementCriteria, | ||
| String detailsForAccommodation, | ||
| Map<String, String> extraInfo, | ||
| @Valid List<@NotNull AdminUnivApplyInfoLanguageRequirementRequest> languageRequirements | ||
| ) { | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import com.example.solidconnection.university.domain.LanguageTestType; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotNull; | ||
|
|
||
| public record AdminUnivApplyInfoLanguageRequirementRequest( | ||
| @NotNull LanguageTestType languageTestType, | ||
| @NotBlank String minScore | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import com.example.solidconnection.university.domain.SemesterAvailableForDispatch; | ||
| import com.example.solidconnection.university.domain.UnivApplyInfo; | ||
| import com.example.solidconnection.university.dto.LanguageRequirementResponse; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public record AdminUnivApplyInfoResponse( | ||
| long id, | ||
| long termId, | ||
| Long homeUniversityId, | ||
| long hostUniversityId, | ||
| String koreanName, | ||
| Integer studentCapacity, | ||
| SemesterAvailableForDispatch semesterAvailableForDispatch, | ||
| String semesterRequirement, | ||
| String detailsForLanguage, | ||
| String gpaRequirement, | ||
| String gpaRequirementCriteria, | ||
| String detailsForAccommodation, | ||
| Map<String, String> extraInfo, | ||
| List<LanguageRequirementResponse> languageRequirements | ||
| ) { | ||
|
|
||
| public static AdminUnivApplyInfoResponse from(UnivApplyInfo univApplyInfo) { | ||
| return new AdminUnivApplyInfoResponse( | ||
| univApplyInfo.getId(), | ||
| univApplyInfo.getTermId(), | ||
| univApplyInfo.getHomeUniversity() != null ? univApplyInfo.getHomeUniversity().getId() : null, | ||
| univApplyInfo.getUniversity().getId(), | ||
| univApplyInfo.getKoreanName(), | ||
| univApplyInfo.getStudentCapacity(), | ||
| univApplyInfo.getSemesterAvailableForDispatch(), | ||
| univApplyInfo.getSemesterRequirement(), | ||
| univApplyInfo.getDetailsForLanguage(), | ||
| univApplyInfo.getGpaRequirement(), | ||
| univApplyInfo.getGpaRequirementCriteria(), | ||
| univApplyInfo.getDetailsForAccommodation(), | ||
| univApplyInfo.getExtraInfo(), | ||
| univApplyInfo.getLanguageRequirements().stream() | ||
| .map(LanguageRequirementResponse::from) | ||
| .sorted() | ||
| .toList() | ||
| ); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.example.solidconnection.admin.university.dto; | ||
|
|
||
| import com.example.solidconnection.university.domain.SemesterAvailableForDispatch; | ||
| import jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public record AdminUnivApplyInfoUpdateRequest( | ||
| Integer studentCapacity, | ||
| SemesterAvailableForDispatch semesterAvailableForDispatch, | ||
| String semesterRequirement, | ||
| String detailsForLanguage, | ||
| String gpaRequirement, | ||
| String gpaRequirementCriteria, | ||
| String detailsForAccommodation, | ||
| Map<String, String> extraInfo, | ||
| @Valid List<@NotNull AdminUnivApplyInfoLanguageRequirementRequest> languageRequirements | ||
| ) { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,17 +3,31 @@ | |
| import static com.example.solidconnection.common.exception.ErrorCode.HOME_UNIVERSITY_NOT_FOUND; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.INVALID_INPUT; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.TERM_NOT_FOUND; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.UNIV_APPLY_INFO_HAS_REFERENCES; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.UNIV_APPLY_INFO_NOT_FOUND; | ||
| import static com.example.solidconnection.common.exception.ErrorCode.UNIVERSITY_NOT_FOUND; | ||
|
|
||
| import com.example.solidconnection.admin.university.dto.AdminUnivApplyInfoCreateRequest; | ||
| import com.example.solidconnection.admin.university.dto.AdminUnivApplyInfoResponse; | ||
| import com.example.solidconnection.admin.university.dto.AdminUnivApplyInfoUpdateRequest; | ||
| import com.example.solidconnection.admin.university.dto.UnivApplyInfoFieldResponse; | ||
| import com.example.solidconnection.admin.university.dto.UnivApplyInfoImportRequest; | ||
| import com.example.solidconnection.admin.university.dto.UnivApplyInfoImportResponse; | ||
| import com.example.solidconnection.application.repository.ApplicationRepository; | ||
| import com.example.solidconnection.cache.annotation.DefaultCacheOut; | ||
| import com.example.solidconnection.common.exception.CustomException; | ||
| import com.example.solidconnection.common.util.MarkdownTableParser; | ||
| import com.example.solidconnection.term.repository.TermRepository; | ||
| import com.example.solidconnection.university.domain.HomeUniversity; | ||
| import com.example.solidconnection.university.domain.HostUniversity; | ||
| import com.example.solidconnection.university.domain.LanguageRequirement; | ||
| import com.example.solidconnection.university.domain.UnivApplyInfo; | ||
| import com.example.solidconnection.university.repository.HomeUniversityRepository; | ||
| import com.example.solidconnection.university.repository.HostUniversityRepository; | ||
| import com.example.solidconnection.university.repository.LikedUnivApplyInfoRepository; | ||
| import com.example.solidconnection.university.repository.UnivApplyInfoRepository; | ||
| import java.util.ArrayList; | ||
| import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import lombok.RequiredArgsConstructor; | ||
|
|
@@ -28,6 +42,10 @@ public class AdminUnivApplyInfoService { | |
| private final HomeUniversityRepository homeUniversityRepository; | ||
| private final MarkdownTableParser markdownTableParser; | ||
| private final AdminUnivApplyInfoRowSaver rowSaver; | ||
| private final UnivApplyInfoRepository univApplyInfoRepository; | ||
| private final HostUniversityRepository hostUniversityRepository; | ||
| private final LikedUnivApplyInfoRepository likedUnivApplyInfoRepository; | ||
| private final ApplicationRepository applicationRepository; | ||
|
|
||
| public UnivApplyInfoFieldResponse getFields() { | ||
| return UnivApplyInfoFieldResponse.of(); | ||
|
|
@@ -75,4 +93,106 @@ private HomeUniversity findHomeUniversity(Long homeUniversityId) { | |
| return homeUniversityRepository.findById(homeUniversityId) | ||
| .orElseThrow(() -> new CustomException(HOME_UNIVERSITY_NOT_FOUND)); | ||
| } | ||
|
|
||
| @Transactional | ||
| @DefaultCacheOut( | ||
| key = {"univApplyInfoTextSearch", "university:recommend:general"}, | ||
| cacheManager = "customCacheManager", | ||
| prefix = true | ||
| ) | ||
| public AdminUnivApplyInfoResponse createUnivApplyInfo(AdminUnivApplyInfoCreateRequest request) { | ||
| validateTermExists(request.termId()); | ||
| HomeUniversity homeUniversity = findHomeUniversity(request.homeUniversityId()); | ||
| HostUniversity hostUniversity = findHostUniversity(request.hostUniversityId()); | ||
|
|
||
| UnivApplyInfo univApplyInfo = new UnivApplyInfo( | ||
| null, | ||
| request.termId(), | ||
| homeUniversity, | ||
| hostUniversity.getKoreanName(), | ||
| request.studentCapacity(), | ||
| request.semesterAvailableForDispatch(), | ||
| request.semesterRequirement(), | ||
| request.detailsForLanguage(), | ||
| request.gpaRequirement(), | ||
| request.gpaRequirementCriteria(), | ||
| request.detailsForAccommodation(), | ||
| request.extraInfo(), | ||
| new HashSet<>(), | ||
| hostUniversity | ||
| ); | ||
|
|
||
| UnivApplyInfo saved = univApplyInfoRepository.save(univApplyInfo); | ||
|
|
||
| if (request.languageRequirements() != null) { | ||
| request.languageRequirements().forEach(lr -> { | ||
| LanguageRequirement languageRequirement = new LanguageRequirement( | ||
| null, lr.languageTestType(), lr.minScore(), saved | ||
| ); | ||
| saved.addLanguageRequirements(languageRequirement); | ||
| }); | ||
| } | ||
|
|
||
| return AdminUnivApplyInfoResponse.from(saved); | ||
| } | ||
|
|
||
| private HostUniversity findHostUniversity(Long hostUniversityId) { | ||
| return hostUniversityRepository.findById(hostUniversityId) | ||
| .orElseThrow(() -> new CustomException(UNIVERSITY_NOT_FOUND)); | ||
| } | ||
|
|
||
| @Transactional | ||
| @DefaultCacheOut( | ||
| key = {"univApplyInfoTextSearch", "university:recommend:general"}, | ||
| cacheManager = "customCacheManager", | ||
|
Comment on lines
+145
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Updating an existing apply info only clears search/recommendation prefixes, but Useful? React with 👍 / 👎. |
||
| prefix = true | ||
| ) | ||
| public AdminUnivApplyInfoResponse updateUnivApplyInfo(long id, AdminUnivApplyInfoUpdateRequest request) { | ||
| UnivApplyInfo univApplyInfo = univApplyInfoRepository.findById(id) | ||
| .orElseThrow(() -> new CustomException(UNIV_APPLY_INFO_NOT_FOUND)); | ||
|
|
||
| univApplyInfo.update( | ||
| request.studentCapacity(), | ||
| request.semesterAvailableForDispatch(), | ||
| request.semesterRequirement(), | ||
| request.detailsForLanguage(), | ||
| request.gpaRequirement(), | ||
| request.gpaRequirementCriteria(), | ||
| request.detailsForAccommodation(), | ||
| request.extraInfo() | ||
| ); | ||
|
|
||
| if (request.languageRequirements() != null) { | ||
| univApplyInfo.clearLanguageRequirements(); | ||
| request.languageRequirements().forEach(lr -> { | ||
| LanguageRequirement languageRequirement = new LanguageRequirement( | ||
| null, lr.languageTestType(), lr.minScore(), univApplyInfo | ||
| ); | ||
| univApplyInfo.addLanguageRequirements(languageRequirement); | ||
| }); | ||
| } | ||
|
|
||
| return AdminUnivApplyInfoResponse.from(univApplyInfo); | ||
| } | ||
|
|
||
| @Transactional | ||
| @DefaultCacheOut( | ||
| key = {"univApplyInfoTextSearch", "university:recommend:general"}, | ||
| cacheManager = "customCacheManager", | ||
| prefix = true | ||
| ) | ||
| public void deleteUnivApplyInfo(long id) { | ||
| UnivApplyInfo univApplyInfo = univApplyInfoRepository.findById(id) | ||
| .orElseThrow(() -> new CustomException(UNIV_APPLY_INFO_NOT_FOUND)); | ||
| validateNoReferences(id); | ||
| univApplyInfoRepository.delete(univApplyInfo); | ||
| } | ||
|
|
||
| private void validateNoReferences(long id) { | ||
| if (likedUnivApplyInfoRepository.existsByUnivApplyInfoId(id) | ||
| || applicationRepository.existsByChoicesUnivApplyInfoId(id)) { | ||
| throw new CustomException(UNIV_APPLY_INFO_HAS_REFERENCES); | ||
| } | ||
| } | ||
|
|
||
| } | ||
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.
When an admin omits
studentCapacityorsemesterAvailableForDispatch(the new request accepts both as null, and the added tests exercise that path), the service stores nulls that public DTOs cannot handle:UnivApplyInfoPreviewResponseunboxesgetStudentCapacity()toint, andUnivApplyInfoDetailResponsedereferencesgetSemesterAvailableForDispatch().getKoreanName(). A newly created current-term record with either field missing can therefore make search/detail endpoints return 500s until the data is repaired, so these fields should be validated as required or the public DTOs made null-safe.Useful? React with 👍 / 👎.