From 159125a12a9a224fa1a668363a8864f6f0a6c696 Mon Sep 17 00:00:00 2001 From: kgc91747 Date: Thu, 8 Aug 2024 16:31:12 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20registration=20=EC=88=98=EA=B0=95=20?= =?UTF-8?q?=ED=98=84=ED=99=A9=20=EC=A1=B0=ED=9A=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/RegistrationRepository.java | 3 +-- .../registration/service/RegistrationService.java | 2 +- .../service/RegistrationServiceImpl.java | 15 +++++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) 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; }