Skip to content

Commit

Permalink
fix: 쿼리 파라미터 변경 (#74)
Browse files Browse the repository at this point in the history
* fix: 쿼리 파라미터 변경

* fix: wrapper 형태로 변경
  • Loading branch information
Ho-Tea authored Jan 23, 2025
1 parent 990a55a commit 778f96e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.List;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import be.dash.dashserver.api.core.member.dto.MyLessonResponse;
import be.dash.dashserver.api.core.member.dto.MyLessonsResponse;
import be.dash.dashserver.api.core.member.dto.ReservationDetailedResponse;
Expand Down Expand Up @@ -55,7 +54,7 @@ public MyLessonDetailedResponse getMyLesson(long memberId, long lessonId) {
.map(Student::getId)
.toList();
List<LocalDateTime> reservationDateTimes = reservations.getCreatedAt();
List<Member> members = memberService.findAllByIds(studentIds);
List<Member> members = memberService.findAllByStudentIds(studentIds);
return MyLessonDetailedResponse.from(lesson, members, reservationDateTimes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
import be.dash.dashserver.core.domain.member.service.MemberRepository;
import be.dash.dashserver.core.domain.teacher.Teacher;
import be.dash.dashserver.core.domain.teacher.service.TeacherRepository;
import be.dash.dashserver.core.log.annotation.Trace;
import be.dash.dashserver.core.exception.ForbiddenException;
import be.dash.dashserver.core.exception.NotFoundException;
import be.dash.dashserver.core.log.annotation.Trace;
import lombok.RequiredArgsConstructor;

@Trace
Expand Down Expand Up @@ -47,7 +47,7 @@ public void createLesson(CreateLessonCommand command) {
lessonRepository.save(lesson);
}

public Lessons getRecommendationLessons(long memberId, LessonSortOption lessonSortOption) {
public Lessons getRecommendationLessons(Long memberId, LessonSortOption lessonSortOption) {
if (isGuest(memberId)) {
Lessons lessons = new Lessons(lessonRepository.findActiveLessons(LocalDateTime.now()));
return lessons.sort(lessonSortOption);
Expand All @@ -59,7 +59,7 @@ public Lessons getRecommendationLessons(long memberId, LessonSortOption lessonSo
return lessons.sort(lessonSortOption);
}

private boolean isGuest(long memberId) {
private boolean isGuest(Long memberId) {
return Objects.isNull(memberId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ public interface MemberRepository {

void updateRole(Long id, Role role);

List<Member> findAllByIds(List<Long> memberIds);
List<Member> findAllByStudentIds(List<Long> studentIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Teacher findTeacherByMemberId(Long memberId) {
.orElseThrow(() -> new ForbiddenException("해당하는 선생님을 찾을 수 없습니다."));
}

public List<Member> findAllByIds(List<Long> memberIds) {
return memberRepository.findAllByIds(memberIds);
public List<Member> findAllByStudentIds(List<Long> studentIds) {
return memberRepository.findAllByStudentIds(studentIds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public void updateRole(Long id, Role role) {
}

@Override
public List<Member> findAllByIds(List<Long> memberIds) {
public List<Member> findAllByStudentIds(List<Long> studentIds) {
List<Long> memberIds = studentJpaRepository.findAllById(studentIds).stream()
.map(studentJpaEntity -> studentJpaEntity.getMember().getId())
.toList();
return memberJpaRepository.findAllById(memberIds).stream().map(MemberJpaEntity::toDomain).toList();
}
}

0 comments on commit 778f96e

Please sign in to comment.