Skip to content

Commit

Permalink
refactor: memberReader에서 조인하는 방식으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
gikhoon committed Jan 22, 2025
1 parent b8acb90 commit bd30378
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
import org.cotato.csquiz.domain.auth.entity.Member;
import org.cotato.csquiz.domain.auth.service.component.MemberReader;
import org.cotato.csquiz.domain.generation.entity.Generation;
import org.cotato.csquiz.domain.generation.entity.GenerationMember;
import org.cotato.csquiz.domain.generation.entity.Session;
import org.cotato.csquiz.domain.generation.repository.GenerationMemberRepository;
import org.cotato.csquiz.domain.generation.service.component.GenerationReader;
import org.cotato.csquiz.domain.generation.service.component.SessionReader;
import org.springframework.stereotype.Service;
Expand All @@ -51,7 +49,6 @@ public class AttendanceRecordService {
private final MemberReader memberReader;
private final GenerationReader generationReader;
private final SessionReader sessionReader;
private final GenerationMemberRepository generationMemberRepository;
private final GenerationMemberAuthValidator authValidator;

public List<GenerationMemberAttendanceRecordResponse> findAttendanceRecords(Long generationId) {
Expand All @@ -78,8 +75,7 @@ public List<AttendanceRecordResponse> findAttendanceRecordsByAttendance(Long att
.orElseThrow(() -> new EntityNotFoundException("해당 출석이 존재하지 않습니다"));
Session session = sessionReader.findById(attendance.getSessionId());

Map<Long, Member> memberById = generationMemberRepository.findAllByGenerationWithMember(session.getGeneration()).stream()
.map(GenerationMember::getMember)
Map<Long, Member> memberById = memberReader.findAllGenerationMember(session.getGeneration()).stream()
.collect(Collectors.toMap(Member::getId, Function.identity()));

Map<Long, AttendanceResult> attendanceResultByMemberId = attendanceRecordRepository.findAllByAttendanceIdAndMemberIdIn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Member findById(Long id) {
}

public List<Member> findAllGenerationMember(Generation generation) {
return generationMemberRepository.findAllByGeneration(generation).stream()
return generationMemberRepository.findAllByGenerationWithMember(generation).stream()
.map(GenerationMember::getMember)
.toList();
}
Expand Down

0 comments on commit bd30378

Please sign in to comment.