Skip to content

Commit

Permalink
refactor: 등록금, 경쟁률 반환하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
nyeroni committed Oct 8, 2024
1 parent 2fb74d1 commit 9ba0e6a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import yerong.wedle.competitionRate.dto.CompetitionRateResponse;
import yerong.wedle.employmentRate.dto.EmploymentRateResponse;

import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
Expand All @@ -17,4 +21,7 @@ public class UniversityAllResponse {
private String website;
private String admissionSite;
private Long starNum;
private List<CompetitionRateResponse> competitionRateResponses;
private List<EmploymentRateResponse> employmentRateResponses;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import yerong.wedle.competitionRate.domain.CompetitionRate;
import yerong.wedle.competitionRate.dto.CompetitionRateResponse;
import yerong.wedle.competitionRate.repository.CompetitionRateRepository;
import yerong.wedle.employmentRate.domain.EmploymentRate;
import yerong.wedle.employmentRate.dto.EmploymentRateResponse;
import yerong.wedle.employmentRate.repository.EmploymentRateRepository;
import yerong.wedle.employmentRate.service.EmploymentRateService;
import yerong.wedle.member.domain.Member;
import yerong.wedle.member.exception.MemberNotFoundException;
import yerong.wedle.member.repository.MemberRepository;
Expand All @@ -24,6 +31,9 @@ public class UniversityService {
private final UniversityRepository universityRepository;
private final StarRepository starRepository;
private final MemberRepository memberRepository;
private final EmploymentRateRepository employmentRateRepository;
private final CompetitionRateRepository competitionRateRepository;

@Transactional
public List<UniversityResponse> searchUniversitiesSummary(String keyward) {
List<University> universities = universityRepository.findByNameContainingOrLocationContaining(keyward, keyward);
Expand Down Expand Up @@ -82,6 +92,17 @@ private UniversityResponse convertToSummaryDto(University university) {
private UniversityAllResponse convertToDetailDto(University university) {
Long starNum = starRepository.countByUniversityId(university.getUniversityId()); // 관심 설정된 횟수 계산

List<CompetitionRate> competitionRates = competitionRateRepository.findByUniversity(university);
List<EmploymentRate> employmentRates = employmentRateRepository.findByUniversity(university); // EmploymentRate 데이터를 가져옵니다.

List<CompetitionRateResponse> competitionRateResponses = competitionRates.stream()
.map(rate -> new CompetitionRateResponse(rate.getEarlyAdmissionRate(), rate.getRegularAdmissionRate(), rate.getCompetitionYear()))
.collect(Collectors.toList());

List<EmploymentRateResponse> employmentRateResponses = employmentRates.stream()
.map(rate -> new EmploymentRateResponse(rate.getEmploymentRate(), rate.getEmploymentYear()))
.collect(Collectors.toList());

return new UniversityAllResponse(
university.getUniversityId(),
university.getName(),
Expand All @@ -91,7 +112,9 @@ private UniversityAllResponse convertToDetailDto(University university) {
university.getPhoneNumber(),
university.getWebsite(),
university.getAdmissionSite(),
starNum
starNum,
competitionRateResponses,
employmentRateResponses
);
}
private String getCurrentUserId() {
Expand Down

0 comments on commit 9ba0e6a

Please sign in to comment.