Merge branch 'be/registration' into 'backend'
feat: registration 수강 현황 조회 추가 See merge request s11-webmobile1-sub2/S11P12A701!113
This commit is contained in:
commit
95f06da233
@ -13,8 +13,7 @@ import java.util.List;
|
|||||||
public interface RegistrationRepository extends JpaRepository<Registration, Long> {
|
public interface RegistrationRepository extends JpaRepository<Registration, Long> {
|
||||||
List<Registration> findAllByUserId(@Param("userId") Long userId);
|
List<Registration> findAllByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
@Query("SELECT r FROM Registration r WHERE r.lecture.id = :lectureId AND r.status = 'WAITING'")
|
List<Registration> findAllByLectureId(Long lectureId);
|
||||||
List<Registration> findAllNotAcceptedByLectureId(@Param("lectureId") Long lectureId);
|
|
||||||
|
|
||||||
Registration findByUserIdAndLectureId(Long userId, Long lectureId);
|
Registration findByUserIdAndLectureId(Long userId, Long lectureId);
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public interface RegistrationService {
|
|||||||
|
|
||||||
boolean deleteRegistration(Long userId, Long registrationId);
|
boolean deleteRegistration(Long userId, Long registrationId);
|
||||||
|
|
||||||
List<RegistrationSearchResponse> searchRegistrations(Long LectureId);
|
List<RegistrationSearchResponse>[] searchRegistrations(Long LectureId);
|
||||||
|
|
||||||
RegistrationStatus getStatus(Long userId, Long lectureId);
|
RegistrationStatus getStatus(Long userId, Long lectureId);
|
||||||
}
|
}
|
||||||
|
@ -74,19 +74,26 @@ public class RegistrationServiceImpl implements RegistrationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RegistrationSearchResponse> searchRegistrations(Long lectureId) {
|
public List<RegistrationSearchResponse>[] searchRegistrations(Long lectureId) {
|
||||||
List<Registration> registrations = registrationRepository.findAllNotAcceptedByLectureId(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) {
|
for (Registration registration : registrations) {
|
||||||
RegistrationSearchResponse response = RegistrationSearchResponse.builder()
|
RegistrationSearchResponse response = RegistrationSearchResponse.builder()
|
||||||
.id(registration.getId())
|
.id(registration.getId())
|
||||||
.userName(registration.getUser().getName())
|
.userName(registration.getUser().getName())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
responses.add(response);
|
if (registration.getStatus() == RegistrationStatus.ACCEPTED) {
|
||||||
|
responses[0].add(response);
|
||||||
|
} else {
|
||||||
|
responses[1].add(response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return responses;
|
return responses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user