Merge pull request #128 from TeamBNBN/be/Lecture

fix: lecture 조회 결과 반환값 수정
This commit is contained in:
Jungmin 2024-07-29 10:56:18 +09:00 committed by GitHub
commit a807a76d8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 18 deletions

View File

@ -35,14 +35,12 @@ public class LectureController {
Lecture lecture = lectureService.findLectureByTitle(lectureCreateRequest.getTitle());
if (lecture != null) {
String msg = new String("Duplicated Lecture");
return new ResponseEntity<>(msg, HttpStatus.CONFLICT);
return new ResponseEntity<>(HttpStatus.CONFLICT);
}
lectureService.createLecture(userId, lectureCreateRequest, image);
String msg = new String("Lecture registered successfully");
return new ResponseEntity<>(msg, HttpStatus.CREATED);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping("/{lectureId}")
@ -50,11 +48,9 @@ public class LectureController {
Long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
if (!lectureService.updateLecture(userId, lectureId, lectureCreateRequest)) {
String msg = new String("Can't update Lecture");
return new ResponseEntity<>(msg, HttpStatus.UNAUTHORIZED);
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
}
String msg = new String("Lecture updated successfully");
return new ResponseEntity<>(msg, HttpStatus.OK);
return new ResponseEntity<>(HttpStatus.OK);
}
@ -63,8 +59,7 @@ public class LectureController {
Long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
if (!lectureService.deleteLecture(userId, lectureId)) {
String msg = new String("Can't delete Lecture");
return new ResponseEntity<>(msg, HttpStatus.UNAUTHORIZED);
return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
}
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
@ -75,8 +70,7 @@ public class LectureController {
List<LectureSearchResponse> lectures = lectureService.findAllLecture();
if (lectures.isEmpty()) {
String msg = new String("No lectures found");
return new ResponseEntity<>(msg, HttpStatus.OK);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(lectures, HttpStatus.OK);
@ -93,8 +87,7 @@ public class LectureController {
LectureDetailResponse lectureDetailResponse = lectureService.findLectureById(userId, lectureId);
if (lectureDetailResponse == null) {
String msg = new String("Can't find Lecture");
return new ResponseEntity<>(msg, HttpStatus.OK);
return new ResponseEntity<>(HttpStatus.OK);
}
@ -104,8 +97,7 @@ public class LectureController {
@GetMapping("/mylecture")
public ResponseEntity<?> findMyLecture(@RequestHeader(value = "Authorization", required = false) String accessToken) {
if (accessToken == null) {
String msg = new String("Not logged in");
return new ResponseEntity<>(msg, HttpStatus.OK);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
Long userId = Long.parseLong(jwtUtil.getUserId(accessToken));
@ -113,8 +105,7 @@ public class LectureController {
List<LectureSearchResponse> myLectures = lectureService.findMyLecture(userId);
if (myLectures.isEmpty()) {
String msg = new String("No lectures found");
return new ResponseEntity<>(msg, HttpStatus.OK);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<>(myLectures, HttpStatus.OK);

View File

@ -119,6 +119,7 @@ public class LectureServiceImpl implements LectureService {
@Override
public List<LectureSearchResponse> findAllLecture() {
List<Lecture> lectureList = lectureRepository.findAll();
System.out.println(lectureList.size());
List<LectureSearchResponse> lectureSearchResponseList = new ArrayList<>();
for (Lecture lecture : lectureList) {