From e2a87acaff80b17a712f6cd0da9a95137d7de37a Mon Sep 17 00:00:00 2001 From: Yeaeun411 Date: Sun, 14 Jan 2024 12:44:50 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EB=A9=94=EC=9D=B8=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20api=20baseresponse=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StudyController.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/umc/StudyFlexBE/controller/StudyController.java b/src/main/java/com/umc/StudyFlexBE/controller/StudyController.java index b93b912..97ca796 100644 --- a/src/main/java/com/umc/StudyFlexBE/controller/StudyController.java +++ b/src/main/java/com/umc/StudyFlexBE/controller/StudyController.java @@ -68,20 +68,32 @@ public BaseResponse participation(@PathVariable Long study_id){ } } @GetMapping("/latest") - public ResponseEntity> getLatestStudies() { - List latestStudies = studyService.getLatestStudies(); - return ResponseEntity.ok(latestStudies); + public BaseResponse getLatestStudies() { + try { + List latestStudies = studyService.getLatestStudies(); + return new BaseResponse<>(BaseResponseStatus.SUCCESS, latestStudies); + }catch (BaseException e){ + return new BaseResponse<>(e.getStatus()); + } } @GetMapping("/open") - public ResponseEntity> getOpenStudies() { - List openStudies = studyService.getOpenStudies(); - return ResponseEntity.ok(openStudies); + public BaseResponse getOpenStudies() { + try { + List openStudies = studyService.getOpenStudies(); + return new BaseResponse<>(BaseResponseStatus.SUCCESS, openStudies); + }catch (BaseException e){ + return new BaseResponse<>(e.getStatus()); + } } @GetMapping("/ranking") - public ResponseEntity> getStudyRanking() { - List rankedStudies = studyService.getRankedStudies(); - return ResponseEntity.ok(rankedStudies); + public BaseResponse getStudyRanking() { + try{ + List rankedStudies = studyService.getRankedStudies(); + return new BaseResponse<>(BaseResponseStatus.SUCCESS, rankedStudies); + }catch (BaseException e){ + return new BaseResponse<>(e.getStatus()); + } } @PostMapping("/{study_id}/postNotice")