diff --git a/backend/src/main/java/com/edufocus/edufocus/registration/repository/RegistrationRepository.java b/backend/src/main/java/com/edufocus/edufocus/registration/repository/RegistrationRepository.java index 327893d..1ea354b 100644 --- a/backend/src/main/java/com/edufocus/edufocus/registration/repository/RegistrationRepository.java +++ b/backend/src/main/java/com/edufocus/edufocus/registration/repository/RegistrationRepository.java @@ -13,8 +13,7 @@ import java.util.List; public interface RegistrationRepository extends JpaRepository { List findAllByUserId(@Param("userId") Long userId); - @Query("SELECT r FROM Registration r WHERE r.lecture.id = :lectureId AND r.status = 'WAITING'") - List findAllNotAcceptedByLectureId(@Param("lectureId") Long lectureId); + List findAllByLectureId(Long lectureId); Registration findByUserIdAndLectureId(Long userId, Long lectureId); diff --git a/backend/src/main/java/com/edufocus/edufocus/registration/service/RegistrationService.java b/backend/src/main/java/com/edufocus/edufocus/registration/service/RegistrationService.java index b01c410..7fc0ece 100644 --- a/backend/src/main/java/com/edufocus/edufocus/registration/service/RegistrationService.java +++ b/backend/src/main/java/com/edufocus/edufocus/registration/service/RegistrationService.java @@ -16,7 +16,7 @@ public interface RegistrationService { boolean deleteRegistration(Long userId, Long registrationId); - List searchRegistrations(Long LectureId); + List[] searchRegistrations(Long LectureId); RegistrationStatus getStatus(Long userId, Long lectureId); } diff --git a/backend/src/main/java/com/edufocus/edufocus/registration/service/RegistrationServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/registration/service/RegistrationServiceImpl.java index 26ac48d..78a539e 100644 --- a/backend/src/main/java/com/edufocus/edufocus/registration/service/RegistrationServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/registration/service/RegistrationServiceImpl.java @@ -74,19 +74,26 @@ public class RegistrationServiceImpl implements RegistrationService { } @Override - public List searchRegistrations(Long lectureId) { - List registrations = registrationRepository.findAllNotAcceptedByLectureId(lectureId); + public List[] searchRegistrations(Long lectureId) { + List registrations = registrationRepository.findAllByLectureId(lectureId); - List responses = new ArrayList<>(); + List[] responses = new ArrayList[2]; + responses[0] = new ArrayList<>(); + responses[1] = new ArrayList<>(); for (Registration registration : registrations) { RegistrationSearchResponse response = RegistrationSearchResponse.builder() .id(registration.getId()) .userName(registration.getUser().getName()) .build(); - responses.add(response); + if (registration.getStatus() == RegistrationStatus.ACCEPTED) { + responses[0].add(response); + } else { + responses[1].add(response); + } } + return responses; }