feat: registration 수강 현황 조회 추가
This commit is contained in:
parent
7f20b2f1ae
commit
159125a12a
@ -13,8 +13,7 @@ import java.util.List;
|
||||
public interface RegistrationRepository extends JpaRepository<Registration, Long> {
|
||||
List<Registration> findAllByUserId(@Param("userId") Long userId);
|
||||
|
||||
@Query("SELECT r FROM Registration r WHERE r.lecture.id = :lectureId AND r.status = 'WAITING'")
|
||||
List<Registration> findAllNotAcceptedByLectureId(@Param("lectureId") Long lectureId);
|
||||
List<Registration> findAllByLectureId(Long lectureId);
|
||||
|
||||
Registration findByUserIdAndLectureId(Long userId, Long lectureId);
|
||||
|
||||
|
@ -16,7 +16,7 @@ public interface RegistrationService {
|
||||
|
||||
boolean deleteRegistration(Long userId, Long registrationId);
|
||||
|
||||
List<RegistrationSearchResponse> searchRegistrations(Long LectureId);
|
||||
List<RegistrationSearchResponse>[] searchRegistrations(Long LectureId);
|
||||
|
||||
RegistrationStatus getStatus(Long userId, Long lectureId);
|
||||
}
|
||||
|
@ -74,18 +74,25 @@ public class RegistrationServiceImpl implements RegistrationService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegistrationSearchResponse> searchRegistrations(Long lectureId) {
|
||||
List<Registration> registrations = registrationRepository.findAllNotAcceptedByLectureId(lectureId);
|
||||
public List<RegistrationSearchResponse>[] searchRegistrations(Long lectureId) {
|
||||
List<Registration> registrations = registrationRepository.findAllByLectureId(lectureId);
|
||||
|
||||
List<RegistrationSearchResponse> responses = new ArrayList<>();
|
||||
List<RegistrationSearchResponse>[] 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user