Merge pull request #131 from TeamBNBN/be/Lecture

fix: Lecture 빈 목록 조회시 반환 타입 수정
This commit is contained in:
yulmam 2024-07-30 10:09:33 +09:00 committed by GitHub
commit ace52afb55
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 24 deletions

View File

@ -14,10 +14,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.UUID;
@RestController @RestController
@RequestMapping("/lecture") @RequestMapping("/lecture")
@ -69,10 +66,6 @@ public class LectureController {
public ResponseEntity<?> findAllLecture() { public ResponseEntity<?> findAllLecture() {
List<LectureSearchResponse> lectures = lectureService.findAllLecture(); List<LectureSearchResponse> lectures = lectureService.findAllLecture();
if (lectures.isEmpty()) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(lectures, HttpStatus.OK); return new ResponseEntity<>(lectures, HttpStatus.OK);
} }
@ -83,14 +76,8 @@ public class LectureController {
if (accessToken != null) { if (accessToken != null) {
userId = Long.parseLong(jwtUtil.getUserId(accessToken)); userId = Long.parseLong(jwtUtil.getUserId(accessToken));
} }
LectureDetailResponse lectureDetailResponse = lectureService.findLectureById(userId, lectureId); LectureDetailResponse lectureDetailResponse = lectureService.findLectureById(userId, lectureId);
if (lectureDetailResponse == null) {
return new ResponseEntity<>(HttpStatus.OK);
}
return new ResponseEntity<>(lectureDetailResponse, HttpStatus.OK); return new ResponseEntity<>(lectureDetailResponse, HttpStatus.OK);
} }
@ -104,10 +91,6 @@ public class LectureController {
List<LectureSearchResponse> myLectures = lectureService.findMyLecture(userId); List<LectureSearchResponse> myLectures = lectureService.findMyLecture(userId);
if (myLectures.isEmpty()) {
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(myLectures, HttpStatus.OK); return new ResponseEntity<>(myLectures, HttpStatus.OK);
} }
} }

View File

@ -18,10 +18,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
@Builder @Builder
@Service @Service
@ -119,7 +116,6 @@ public class LectureServiceImpl implements LectureService {
@Override @Override
public List<LectureSearchResponse> findAllLecture() { public List<LectureSearchResponse> findAllLecture() {
List<Lecture> lectureList = lectureRepository.findAll(); List<Lecture> lectureList = lectureRepository.findAll();
System.out.println(lectureList.size());
List<LectureSearchResponse> lectureSearchResponseList = new ArrayList<>(); List<LectureSearchResponse> lectureSearchResponseList = new ArrayList<>();
for (Lecture lecture : lectureList) { for (Lecture lecture : lectureList) {
@ -137,11 +133,9 @@ public class LectureServiceImpl implements LectureService {
@Override @Override
public LectureDetailResponse findLectureById(Long userId, long lectureId) { public LectureDetailResponse findLectureById(Long userId, long lectureId) {
Optional<Lecture> lecture = lectureRepository.findById(lectureId); Optional<Lecture> lecture = lectureRepository.findById(lectureId);
if (lecture.isEmpty()) { if (lecture.isEmpty()) {
return null; return null;
} }
lecture = Optional.of(lecture.get());
String userStatus; String userStatus;
if (userId == null) { if (userId == null) {