feat: Registration 미승인 수강신청 조회, 중복신청 확인 추가
This commit is contained in:
parent
e0f5168638
commit
75a4baf782
@ -29,7 +29,7 @@ public class RegistrationController {
|
|||||||
Long lectureId = map.get("lectureId");
|
Long lectureId = map.get("lectureId");
|
||||||
|
|
||||||
if (!registrationService.createRegistration(userId, lectureId)) {
|
if (!registrationService.createRegistration(userId, lectureId)) {
|
||||||
return new ResponseEntity<>(HttpStatus.CONFLICT);
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||||
|
@ -12,6 +12,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> findAllNotAcceptedByLectureId(@Param("lectureId") Long lectureId);
|
List<Registration> findAllNotAcceptedByLectureId(@Param("lectureId") Long lectureId);
|
||||||
|
|
||||||
Registration findByUserIdAndLectureId(Long userId, Long lectureId);
|
Registration findByUserIdAndLectureId(Long userId, Long lectureId);
|
||||||
|
@ -18,5 +18,5 @@ public interface RegistrationService {
|
|||||||
|
|
||||||
List<RegistrationSearchResponse> searchRegistrations(Long LectureId);
|
List<RegistrationSearchResponse> searchRegistrations(Long LectureId);
|
||||||
|
|
||||||
//RegistrationStatus getStatus(Long userId, Long lectureId);
|
RegistrationStatus getStatus(Long userId, Long lectureId);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,11 @@ public class RegistrationServiceImpl implements RegistrationService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Registration registration = new Registration().builder()
|
if (registrationRepository.findByUserIdAndLectureId(userId, lectureId) != null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Registration registration = Registration.builder()
|
||||||
.user(userRepository.findById(userId).get())
|
.user(userRepository.findById(userId).get())
|
||||||
.lecture(lectureRepository.findById(lectureId).get())
|
.lecture(lectureRepository.findById(lectureId).get())
|
||||||
.status(RegistrationStatus.WAITING)
|
.status(RegistrationStatus.WAITING)
|
||||||
@ -76,7 +80,7 @@ public class RegistrationServiceImpl implements RegistrationService {
|
|||||||
|
|
||||||
List<RegistrationSearchResponse> responses = new ArrayList<>();
|
List<RegistrationSearchResponse> responses = new ArrayList<>();
|
||||||
for (Registration registration : registrations) {
|
for (Registration registration : registrations) {
|
||||||
RegistrationSearchResponse response = new RegistrationSearchResponse().builder()
|
RegistrationSearchResponse response = RegistrationSearchResponse.builder()
|
||||||
.id(registration.getId())
|
.id(registration.getId())
|
||||||
.userName(registration.getUser().getName())
|
.userName(registration.getUser().getName())
|
||||||
.build();
|
.build();
|
||||||
@ -87,11 +91,11 @@ public class RegistrationServiceImpl implements RegistrationService {
|
|||||||
return responses;
|
return responses;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
@Override
|
||||||
// public RegistrationStatus getStatus(Long userId, Long lectureId) {
|
public RegistrationStatus getStatus(Long userId, Long lectureId) {
|
||||||
//
|
|
||||||
// Registration registration = registrationRepository.findByUserIdAndLectureId(userId, lectureId);
|
Registration registration = registrationRepository.findByUserIdAndLectureId(userId, lectureId);
|
||||||
// return registration.getStatus();
|
return registration.getStatus();
|
||||||
// }
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user