From bae37123af6eff23efc5a7d6e83b0ad327ac9d27 Mon Sep 17 00:00:00 2001 From: thguss Date: Wed, 13 Mar 2024 01:20:11 +0900 Subject: [PATCH 01/11] =?UTF-8?q?[ADD]=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20Res?= =?UTF-8?q?ponse=20=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/smeem/api/common/ApiResponseUtil.java | 6 ++++ .../com/smeem/api/common/BaseResponse.java | 8 ++--- .../com/smeem/api/common/ErrorResponse.java | 16 ++++++++++ .../com/smeem/api/diary/api/DiaryApi.java | 30 +++++++++++++++---- .../api/diary/api/DiaryApiController.java | 4 +-- 5 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java diff --git a/smeem-api/src/main/java/com/smeem/api/common/ApiResponseUtil.java b/smeem-api/src/main/java/com/smeem/api/common/ApiResponseUtil.java index 86b34e23..ec4b2fb0 100644 --- a/smeem-api/src/main/java/com/smeem/api/common/ApiResponseUtil.java +++ b/smeem-api/src/main/java/com/smeem/api/common/ApiResponseUtil.java @@ -20,6 +20,12 @@ static ResponseEntity> success(SuccessCode code, T data) { .body(BaseResponse.of(code.getMessage(), data)); } + static ResponseEntity> successTest(SuccessCode code, T data) { + return ResponseEntity + .status(code.getStatus()) + .body(BaseResponse.of(code.getMessage(), data)); + } + static ResponseEntity> success(SuccessCode code, URI uri, T data) { return ResponseEntity .status(code.getStatus()) diff --git a/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java b/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java index b72b470f..f3e8b63c 100644 --- a/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java +++ b/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java @@ -14,12 +14,8 @@ public record BaseResponse( T data ) { - public static BaseResponse of(String message, T data) { - return BaseResponse.builder() - .success(true) - .message(message) - .data(data) - .build(); + public static BaseResponse of(String message, T data) { + return new BaseResponse<>(true, message, data); } public static BaseResponse of(boolean isSuccess, String message) { diff --git a/smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java b/smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java new file mode 100644 index 00000000..b6f7c63a --- /dev/null +++ b/smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java @@ -0,0 +1,16 @@ +package com.smeem.api.common; + +import lombok.Builder; + +import static lombok.AccessLevel.PRIVATE; + +@Builder(access = PRIVATE) +public record ErrorResponse( + boolean success, + String message +) { + + public static ErrorResponse of(String message) { + return new ErrorResponse(false, message); + } +} diff --git a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java index c222892d..4dacf3ef 100644 --- a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java +++ b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java @@ -1,10 +1,15 @@ package com.smeem.api.diary.api; import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.ErrorResponse; import com.smeem.api.diary.api.dto.request.DiaryCreateRequest; import com.smeem.api.diary.api.dto.request.DiaryModifyRequest; +import com.smeem.api.diary.api.dto.response.DiaryCreateResponse; +import com.smeem.api.diary.api.dto.response.DiaryGetResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -33,12 +38,27 @@ public interface DiaryApi { @Operation(summary = "일기 상세 조회 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "201", + description = "성공" + ), + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)) + ), + @ApiResponse( + responseCode = "401", + description = "유효하지 않은 토큰", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)) + ) }) - ResponseEntity> getDiaryDetail(@PathVariable long diaryId); + ResponseEntity> getDiaryDetail(@PathVariable long diaryId); @Operation(summary = "일기 수정 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) diff --git a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java index 7192fe4c..b5580da8 100644 --- a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java @@ -48,10 +48,10 @@ public ResponseEntity> createDiary(Principal principal, @Request } @GetMapping("/{diaryId}") - public ResponseEntity> getDiaryDetail(@PathVariable long diaryId) { + public ResponseEntity> getDiaryDetail(@PathVariable long diaryId) { val response = DiaryGetResponse.from( diaryQueryService.getDiaryDetail(DiaryGetServiceRequest.of(diaryId))); - return ApiResponseUtil.success(SUCCESS_GET_DIARY, response); + return ApiResponseUtil.successTest(SUCCESS_GET_DIARY, response); } @PatchMapping("/{diaryId}") From bc023ad349a43ff6b57bdf94f2a86d1160d361fb Mon Sep 17 00:00:00 2001 From: thguss Date: Sun, 17 Mar 2024 22:41:05 +0900 Subject: [PATCH 02/11] =?UTF-8?q?[REFACTOR]=20=EC=8A=A4=EC=9B=A8=EA=B1=B0?= =?UTF-8?q?=20=EC=9D=91=EB=8B=B5=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/smeem/api/common/BaseResponse.java | 6 ++++- .../com/smeem/api/common/ErrorResponse.java | 16 ------------ .../com/smeem/api/diary/api/DiaryApi.java | 26 +++---------------- 3 files changed, 9 insertions(+), 39 deletions(-) delete mode 100644 smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java diff --git a/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java b/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java index f3e8b63c..c258068e 100644 --- a/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java +++ b/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java @@ -15,7 +15,11 @@ public record BaseResponse( ) { public static BaseResponse of(String message, T data) { - return new BaseResponse<>(true, message, data); + return BaseResponse.builder() + .success(true) + .message(message) + .data(data) + .build(); } public static BaseResponse of(boolean isSuccess, String message) { diff --git a/smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java b/smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java deleted file mode 100644 index b6f7c63a..00000000 --- a/smeem-api/src/main/java/com/smeem/api/common/ErrorResponse.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.smeem.api.common; - -import lombok.Builder; - -import static lombok.AccessLevel.PRIVATE; - -@Builder(access = PRIVATE) -public record ErrorResponse( - boolean success, - String message -) { - - public static ErrorResponse of(String message) { - return new ErrorResponse(false, message); - } -} diff --git a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java index 4dacf3ef..e1ee209e 100644 --- a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java +++ b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java @@ -1,15 +1,12 @@ package com.smeem.api.diary.api; import com.smeem.api.common.BaseResponse; -import com.smeem.api.common.ErrorResponse; import com.smeem.api.diary.api.dto.request.DiaryCreateRequest; import com.smeem.api.diary.api.dto.request.DiaryModifyRequest; -import com.smeem.api.diary.api.dto.response.DiaryCreateResponse; import com.smeem.api.diary.api.dto.response.DiaryGetResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -38,25 +35,10 @@ public interface DiaryApi { @Operation(summary = "일기 상세 조회 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @ApiResponses(value = { - @ApiResponse( - responseCode = "201", - description = "성공" - ), - @ApiResponse( - responseCode = "4xx", - description = "유효하지 않은 요청", - content = @Content(schema = @Schema(implementation = ErrorResponse.class)) - ), - @ApiResponse( - responseCode = "401", - description = "유효하지 않은 토큰", - content = @Content(schema = @Schema(implementation = ErrorResponse.class)) - ), - @ApiResponse( - responseCode = "500", - description = "서버 내부 오류", - content = @Content(schema = @Schema(implementation = ErrorResponse.class)) - ) + @ApiResponse(responseCode = "201", description = "성공"), + @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청", content = @Content), + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰", content = @Content), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content) }) ResponseEntity> getDiaryDetail(@PathVariable long diaryId); From 54a5e075c5febc035e2e8f9623765dacc25f0952 Mon Sep 17 00:00:00 2001 From: thguss Date: Wed, 20 Mar 2024 16:18:41 +0900 Subject: [PATCH 03/11] =?UTF-8?q?[FIX]=20=EC=95=84=EC=9A=94=20=EA=B6=8C?= =?UTF-8?q?=EC=9E=A5=20=EC=95=B1=20=EB=B2=84=EC=A0=84=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smeem-api/src/main/resources/application-prod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smeem-api/src/main/resources/application-prod.yml b/smeem-api/src/main/resources/application-prod.yml index ad9cecb5..1814eb1d 100644 --- a/smeem-api/src/main/resources/application-prod.yml +++ b/smeem-api/src/main/resources/application-prod.yml @@ -48,7 +48,7 @@ smeem: title: "업데이트 알림" content: "보다 나아진 스밈의 최신 버전을 준비했어요! 새로운 버전으로 업데이트 후 이용해주세요." ios: - app: 2.0.0 + app: 2.0.1 force: 2.0.0 # 심사 통과 후 3.0.0 업데이트 필요 discord: From ba9d20b1e1be4537f4ca1cf45ecda9d00b460458 Mon Sep 17 00:00:00 2001 From: thguss Date: Wed, 20 Mar 2024 16:25:38 +0900 Subject: [PATCH 04/11] =?UTF-8?q?[REFACTOR]=20BaseResponse=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/smeem/api/auth/api/AuthApi.java | 10 ++++---- .../smeem/api/auth/api/AuthController.java | 12 +++++----- .../CustomJwtAuthenticationEntryPoint.java | 4 ++-- .../com/smeem/api/badge/api/BadgeApi.java | 4 ++-- .../smeem/api/badge/api/BadgeController.java | 4 ++-- .../com/smeem/api/common/ApiResponseUtil.java | 24 ++++++++----------- .../api/common/advicer/ErrorHandler.java | 24 +++++++++---------- .../smeem/api/common/dto/FailureResponse.java | 19 +++++++++++++++ .../SuccessResponse.java} | 14 +++++------ .../com/smeem/api/diary/api/DiaryApi.java | 12 +++++----- .../api/diary/api/DiaryApiController.java | 12 +++++----- .../java/com/smeem/api/goal/api/GoalApi.java | 6 ++--- .../smeem/api/goal/api/GoalApiController.java | 6 ++--- .../com/smeem/api/member/api/MemberApi.java | 13 +++++----- .../api/member/api/MemberController.java | 12 +++++----- .../java/com/smeem/api/test/api/TestApi.java | 6 ++--- .../smeem/api/test/api/TestApiController.java | 6 ++--- .../com/smeem/api/topic/api/TopicApi.java | 4 ++-- .../api/topic/api/TopicApiController.java | 4 ++-- .../com/smeem/api/version/api/VersionApi.java | 4 ++-- .../api/version/api/VersionApiController.java | 4 ++-- .../api/controller/DiaryControllerTest.java | 2 +- 22 files changed, 110 insertions(+), 96 deletions(-) create mode 100644 smeem-api/src/main/java/com/smeem/api/common/dto/FailureResponse.java rename smeem-api/src/main/java/com/smeem/api/common/{BaseResponse.java => dto/SuccessResponse.java} (62%) diff --git a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java index 92777064..79d39674 100644 --- a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java +++ b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java @@ -1,7 +1,7 @@ package com.smeem.api.auth.api; import com.smeem.api.auth.api.dto.request.SignInRequest; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -28,7 +28,7 @@ public interface AuthApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException; + ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException; @Operation(summary = "토큰 재발급 API") @Parameter(name = "Authorization", description = "Bearer ${Smeme Refresh Token}", in = HEADER, required = true) @@ -37,7 +37,7 @@ public interface AuthApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> reissueToken(Principal principal); + ResponseEntity> reissueToken(Principal principal); @Operation(summary = "사용자 로그아웃 API") @@ -47,7 +47,7 @@ public interface AuthApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> signOut(Principal principal); + ResponseEntity> signOut(Principal principal); @Operation(summary = "회원 탈퇴 API") @@ -57,6 +57,6 @@ public interface AuthApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> withDrawl(Principal principal); + ResponseEntity> withDrawl(Principal principal); } diff --git a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthController.java b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthController.java index 3ac1bc4a..e13fb133 100644 --- a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthController.java +++ b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthController.java @@ -7,7 +7,7 @@ import com.smeem.api.auth.service.TokenService; import com.smeem.api.auth.service.dto.request.SignInServiceRequest; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.common.util.Util; import lombok.RequiredArgsConstructor; import lombok.val; @@ -31,29 +31,29 @@ public class AuthController implements AuthApi { @Override @PostMapping - public ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, - @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException { + public ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, + @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException { val response = SignInResponse.from(authService.signIn(socialAccessToken, SignInServiceRequest.of(request))); return ApiResponseUtil.success(SUCCESS_SIGNIN, response); } @Override @PostMapping("/token") - public ResponseEntity> reissueToken(Principal principal) { + public ResponseEntity> reissueToken(Principal principal) { val response = TokenResponse.from(tokenService.issueToken(Util.getMemberId(principal))); return ApiResponseUtil.success(SUCCESS_ISSUE_TOKEN, response); } @Override @PostMapping("/sign-out") - public ResponseEntity> signOut(Principal principal) { + public ResponseEntity> signOut(Principal principal) { authService.signOut(Util.getMemberId(principal)); return ApiResponseUtil.success(SUCCESS_SIGNOUT); } @Override @DeleteMapping - public ResponseEntity> withDrawl(Principal principal) { + public ResponseEntity> withDrawl(Principal principal) { authService.withdraw(Util.getMemberId(principal)); return ApiResponseUtil.success(SUCCESS_WITHDRAW); } diff --git a/smeem-api/src/main/java/com/smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java b/smeem-api/src/main/java/com/smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java index df4e1499..ea7e25d4 100644 --- a/smeem-api/src/main/java/com/smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java +++ b/smeem-api/src/main/java/com/smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.springframework.http.MediaType; @@ -32,7 +32,7 @@ private void setResponse(HttpServletResponse response) throws IOException { response.getWriter().println(objectMapper.writeValueAsString(getFailureResponse())); } - private ResponseEntity> getFailureResponse() { + private ResponseEntity> getFailureResponse() { return ApiResponseUtil.failure(INVALID_TOKEN); } } diff --git a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java index f30aed04..159a55a3 100644 --- a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java +++ b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java @@ -1,6 +1,6 @@ package com.smeem.api.badge.api; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -23,6 +23,6 @@ public interface BadgeApi { @ApiResponse(responseCode = "4011", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getBadges(Principal principal); + ResponseEntity> getBadges(Principal principal); } diff --git a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeController.java b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeController.java index d2aa7595..ee17d51c 100644 --- a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeController.java +++ b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeController.java @@ -3,7 +3,7 @@ import com.smeem.api.badge.api.dto.response.BadgeListResponse; import com.smeem.api.badge.service.BadgeService; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.common.util.Util; import lombok.RequiredArgsConstructor; import lombok.val; @@ -25,7 +25,7 @@ public class BadgeController implements BadgeApi { @Override @GetMapping - public ResponseEntity> getBadges(Principal principal) { + public ResponseEntity> getBadges(Principal principal) { val response = BadgeListResponse.from(badgeService.getBadges(Util.getMemberId(principal))); return ApiResponseUtil.success(SUCCESS_GET_BADGES, response); } diff --git a/smeem-api/src/main/java/com/smeem/api/common/ApiResponseUtil.java b/smeem-api/src/main/java/com/smeem/api/common/ApiResponseUtil.java index ec4b2fb0..a462c3a6 100644 --- a/smeem-api/src/main/java/com/smeem/api/common/ApiResponseUtil.java +++ b/smeem-api/src/main/java/com/smeem/api/common/ApiResponseUtil.java @@ -1,5 +1,7 @@ package com.smeem.api.common; +import com.smeem.api.common.dto.FailureResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.common.code.failure.FailureCode; import com.smeem.common.code.success.SuccessCode; import org.springframework.http.ResponseEntity; @@ -8,34 +10,28 @@ public interface ApiResponseUtil { - static ResponseEntity> success(SuccessCode code) { + static ResponseEntity> success(SuccessCode code) { return ResponseEntity .status(code.getStatus()) - .body(BaseResponse.of(true, code.getMessage())); + .body(SuccessResponse.of(code.getMessage())); } - static ResponseEntity> success(SuccessCode code, T data) { + static ResponseEntity> success(SuccessCode code, T data) { return ResponseEntity .status(code.getStatus()) - .body(BaseResponse.of(code.getMessage(), data)); + .body(SuccessResponse.of(code.getMessage(), data)); } - static ResponseEntity> successTest(SuccessCode code, T data) { - return ResponseEntity - .status(code.getStatus()) - .body(BaseResponse.of(code.getMessage(), data)); - } - - static ResponseEntity> success(SuccessCode code, URI uri, T data) { + static ResponseEntity> success(SuccessCode code, URI uri, T data) { return ResponseEntity .status(code.getStatus()) .location(uri) - .body(BaseResponse.of(code.getMessage(), data)); + .body(SuccessResponse.of(code.getMessage(), data)); } - static ResponseEntity> failure(FailureCode code) { + static ResponseEntity failure(FailureCode code) { return ResponseEntity .status(code.getStatus()) - .body(BaseResponse.of(false, code.getMessage())); + .body(FailureResponse.of(code.getMessage())); } } diff --git a/smeem-api/src/main/java/com/smeem/api/common/advicer/ErrorHandler.java b/smeem-api/src/main/java/com/smeem/api/common/advicer/ErrorHandler.java index ca0f1637..59bc0870 100644 --- a/smeem-api/src/main/java/com/smeem/api/common/advicer/ErrorHandler.java +++ b/smeem-api/src/main/java/com/smeem/api/common/advicer/ErrorHandler.java @@ -1,7 +1,7 @@ package com.smeem.api.common.advicer; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.common.exception.*; import com.smeem.external.discord.DiscordAlarmSender; import lombok.RequiredArgsConstructor; @@ -19,57 +19,57 @@ public class ErrorHandler { private final DiscordAlarmSender discordAlarmSender; @ExceptionHandler(TrainingTimeException.class) - public ResponseEntity> trainingTimeException(TrainingTimeException exception) { + public ResponseEntity> trainingTimeException(TrainingTimeException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(TokenException.class) - public ResponseEntity> tokenException(TokenException exception) { + public ResponseEntity> tokenException(TokenException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(BadgeException.class) - public ResponseEntity> badgeException(BadgeException exception) { + public ResponseEntity> badgeException(BadgeException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(DiaryException.class) - public ResponseEntity> diaryException(DiaryException exception) { + public ResponseEntity> diaryException(DiaryException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(MemberException.class) - public ResponseEntity> memberException(MemberException exception) { + public ResponseEntity> memberException(MemberException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(GoalException.class) - public ResponseEntity> goalException(GoalException exception) { + public ResponseEntity> goalException(GoalException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(TopicException.class) - public ResponseEntity> topicException(TopicException exception) { + public ResponseEntity> topicException(TopicException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(AppleException.class) - public ResponseEntity> appleException(AppleException exception) { + public ResponseEntity> appleException(AppleException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(FcmException.class) - public ResponseEntity> fcmException(FcmException exception) { + public ResponseEntity> fcmException(FcmException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(AuthException.class) - public ResponseEntity> authException(AuthException exception) { + public ResponseEntity> authException(AuthException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(RuntimeException.class) - public ResponseEntity> baseException(RuntimeException exception) { + public ResponseEntity> baseException(RuntimeException exception) { sendDiscordAlarm(exception); return ApiResponseUtil.failure(SERVER_ERROR); } diff --git a/smeem-api/src/main/java/com/smeem/api/common/dto/FailureResponse.java b/smeem-api/src/main/java/com/smeem/api/common/dto/FailureResponse.java new file mode 100644 index 00000000..e8168a32 --- /dev/null +++ b/smeem-api/src/main/java/com/smeem/api/common/dto/FailureResponse.java @@ -0,0 +1,19 @@ +package com.smeem.api.common.dto; + +import lombok.Builder; + +import static lombok.AccessLevel.PRIVATE; + +@Builder(access = PRIVATE) +public record FailureResponse( + boolean success, + String message +) { + + public static FailureResponse of(String message) { + return FailureResponse.builder() + .success(false) + .message(message) + .build(); + } +} diff --git a/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java b/smeem-api/src/main/java/com/smeem/api/common/dto/SuccessResponse.java similarity index 62% rename from smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java rename to smeem-api/src/main/java/com/smeem/api/common/dto/SuccessResponse.java index c258068e..ee551e2c 100644 --- a/smeem-api/src/main/java/com/smeem/api/common/BaseResponse.java +++ b/smeem-api/src/main/java/com/smeem/api/common/dto/SuccessResponse.java @@ -1,4 +1,4 @@ -package com.smeem.api.common; +package com.smeem.api.common.dto; import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Builder; @@ -7,24 +7,24 @@ import static lombok.AccessLevel.PRIVATE; @Builder(access = PRIVATE) -public record BaseResponse( +public record SuccessResponse( boolean success, String message, @JsonInclude(value = NON_NULL) T data ) { - public static BaseResponse of(String message, T data) { - return BaseResponse.builder() + public static SuccessResponse of(String message, T data) { + return SuccessResponse.builder() .success(true) .message(message) .data(data) .build(); } - public static BaseResponse of(boolean isSuccess, String message) { - return BaseResponse.builder() - .success(isSuccess) + public static SuccessResponse of(String message) { + return SuccessResponse.builder() + .success(true) .message(message) .build(); } diff --git a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java index e1ee209e..c4d805a2 100644 --- a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java +++ b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java @@ -1,6 +1,6 @@ package com.smeem.api.diary.api; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.diary.api.dto.request.DiaryCreateRequest; import com.smeem.api.diary.api.dto.request.DiaryModifyRequest; import com.smeem.api.diary.api.dto.response.DiaryGetResponse; @@ -30,7 +30,7 @@ public interface DiaryApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> createDiary(Principal principal, @RequestBody DiaryCreateRequest request); + ResponseEntity> createDiary(Principal principal, @RequestBody DiaryCreateRequest request); @Operation(summary = "일기 상세 조회 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @@ -40,7 +40,7 @@ public interface DiaryApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰", content = @Content), @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content) }) - ResponseEntity> getDiaryDetail(@PathVariable long diaryId); + ResponseEntity> getDiaryDetail(@PathVariable long diaryId); @Operation(summary = "일기 수정 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @@ -50,7 +50,7 @@ public interface DiaryApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> modifyDiary(@PathVariable long diaryId, @RequestBody DiaryModifyRequest request); + ResponseEntity> modifyDiary(@PathVariable long diaryId, @RequestBody DiaryModifyRequest request); @Operation(summary = "일기 삭제 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @@ -60,7 +60,7 @@ public interface DiaryApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> deleteDiary(@PathVariable long diaryId); + ResponseEntity> deleteDiary(@PathVariable long diaryId); @Operation(summary = "기간 내 일기 목록 조회 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @@ -70,7 +70,7 @@ public interface DiaryApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getDiaries( + ResponseEntity> getDiaries( Principal principal, @RequestParam String start, @RequestParam String end diff --git a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java index b5580da8..75190f61 100644 --- a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java @@ -3,7 +3,7 @@ import java.security.Principal; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.diary.api.dto.request.DiaryCreateRequest; import com.smeem.api.diary.api.dto.request.DiaryModifyRequest; import com.smeem.api.diary.api.dto.response.DiaryCreateResponse; @@ -39,7 +39,7 @@ public class DiaryApiController implements DiaryApi { private final DiaryQueryService diaryQueryService; @PostMapping - public ResponseEntity> createDiary(Principal principal, @RequestBody DiaryCreateRequest request) { + public ResponseEntity> createDiary(Principal principal, @RequestBody DiaryCreateRequest request) { val memberId = Util.getMemberId(principal); val response = DiaryCreateResponse.from( diaryCommandService.createDiary(DiaryCreateServiceRequest.of(memberId, request))); @@ -48,26 +48,26 @@ public ResponseEntity> createDiary(Principal principal, @Request } @GetMapping("/{diaryId}") - public ResponseEntity> getDiaryDetail(@PathVariable long diaryId) { + public ResponseEntity> getDiaryDetail(@PathVariable long diaryId) { val response = DiaryGetResponse.from( diaryQueryService.getDiaryDetail(DiaryGetServiceRequest.of(diaryId))); return ApiResponseUtil.successTest(SUCCESS_GET_DIARY, response); } @PatchMapping("/{diaryId}") - public ResponseEntity> modifyDiary(@PathVariable long diaryId, @RequestBody DiaryModifyRequest request) { + public ResponseEntity> modifyDiary(@PathVariable long diaryId, @RequestBody DiaryModifyRequest request) { diaryCommandService.modifyDiary(DiaryModifyServiceRequest.of(diaryId, request)); return ApiResponseUtil.success(SUCCESS_UPDATE_DAIRY); } @DeleteMapping("/{diaryId}") - public ResponseEntity> deleteDiary(@PathVariable long diaryId) { + public ResponseEntity> deleteDiary(@PathVariable long diaryId) { diaryCommandService.deleteDiary(DiaryDeleteServiceRequest.of(diaryId)); return ApiResponseUtil.success(SUCCESS_DELETE_DIARY); } @GetMapping - public ResponseEntity> getDiaries( + public ResponseEntity> getDiaries( Principal principal, @RequestParam String start, @RequestParam String end diff --git a/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java b/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java index 830965c0..2a38b006 100644 --- a/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java +++ b/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java @@ -1,6 +1,6 @@ package com.smeem.api.goal.api; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.domain.goal.model.GoalType; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -18,7 +18,7 @@ public interface GoalApi { @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getAllGoals(); + ResponseEntity> getAllGoals(); @Operation(summary = "목표 상세 조회 API") @ApiResponses(value = { @@ -26,5 +26,5 @@ public interface GoalApi { @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getGoalByType(@PathVariable GoalType type); + ResponseEntity> getGoalByType(@PathVariable GoalType type); } diff --git a/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApiController.java b/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApiController.java index 539f7e27..4cf07890 100644 --- a/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApiController.java @@ -1,7 +1,7 @@ package com.smeem.api.goal.api; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.goal.api.dto.response.GoalGetResponse; import com.smeem.api.goal.api.dto.response.GoalListGetResponse; @@ -28,13 +28,13 @@ public class GoalApiController implements GoalApi { private final GoalService goalService; @GetMapping - public ResponseEntity> getAllGoals() { + public ResponseEntity> getAllGoals() { val response = GoalListGetResponse.from(goalService.getAllGoals()); return ApiResponseUtil.success(SUCCESS_GET_GOALS, response); } @GetMapping("/{type}") - public ResponseEntity> getGoalByType(@PathVariable GoalType type) { + public ResponseEntity> getGoalByType(@PathVariable GoalType type) { val response = GoalGetResponse.from(goalService.getByType(GoalGetServiceRequest.of(type))); return ApiResponseUtil.success(SUCCESS_GET_GOAL, response); } diff --git a/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java b/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java index 6761ca11..9f0d7959 100644 --- a/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java +++ b/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java @@ -1,12 +1,11 @@ package com.smeem.api.member.api; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.member.api.dto.request.MemberPlanUpdateRequest; import com.smeem.api.member.api.dto.request.MemberPushUpdateRequest; import com.smeem.api.member.api.dto.request.MemberUpdateRequest; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -29,7 +28,7 @@ public interface MemberApi { @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), @ApiResponse(responseCode = "500", description = "서버 오류") }) - ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request); + ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request); @Operation(summary = "사용자 프로필 조회 API") @@ -39,7 +38,7 @@ public interface MemberApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getProfile(Principal principal); + ResponseEntity> getProfile(Principal principal); @Operation(summary = "사용자 학습 계획 수정 API") @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @@ -49,7 +48,7 @@ public interface MemberApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> updateUserPlan(Principal principal, @Valid @RequestBody MemberPlanUpdateRequest request); + ResponseEntity> updateUserPlan(Principal principal, @Valid @RequestBody MemberPlanUpdateRequest request); @Operation(summary = "사용자 닉네임 중복체크 수정 API") @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @@ -58,7 +57,7 @@ public interface MemberApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임") @RequestParam String name); + ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임") @RequestParam String name); @Operation(summary = "사용자 학습 계획 수정 API") @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @@ -67,5 +66,5 @@ public interface MemberApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> updateUserPush(Principal principal, @RequestBody MemberPushUpdateRequest request); + ResponseEntity> updateUserPush(Principal principal, @RequestBody MemberPushUpdateRequest request); } diff --git a/smeem-api/src/main/java/com/smeem/api/member/api/MemberController.java b/smeem-api/src/main/java/com/smeem/api/member/api/MemberController.java index f8bc4bf2..0ee86eb6 100644 --- a/smeem-api/src/main/java/com/smeem/api/member/api/MemberController.java +++ b/smeem-api/src/main/java/com/smeem/api/member/api/MemberController.java @@ -1,7 +1,7 @@ package com.smeem.api.member.api; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.member.api.dto.request.MemberPlanUpdateRequest; import com.smeem.api.member.api.dto.request.MemberPushUpdateRequest; import com.smeem.api.member.api.dto.request.MemberUpdateRequest; @@ -33,7 +33,7 @@ public class MemberController implements MemberApi { @Override @PatchMapping - public ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request) { + public ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request) { val response = MemberUpdateResponse.from(memberService.updateUserProfile( Util.getMemberId(principal), MemberServiceUpdateUserProfileRequest.of(request))); @@ -42,28 +42,28 @@ public ResponseEntity> updateProfile(Principal principal, @Reque @Override @GetMapping("/me") - public ResponseEntity> getProfile(Principal principal) { + public ResponseEntity> getProfile(Principal principal) { val response = MemberGetResponse.from(memberService.getMemberProfile(Util.getMemberId(principal))); return ApiResponseUtil.success(SUCCESS_GET_USER, response); } @Override @PatchMapping("/plan") - public ResponseEntity> updateUserPlan(Principal principal, @Valid @RequestBody MemberPlanUpdateRequest request) { + public ResponseEntity> updateUserPlan(Principal principal, @Valid @RequestBody MemberPlanUpdateRequest request) { memberService.updateLearningPlan(Util.getMemberId(principal), MemberUpdatePlanServiceRequest.of(request)); return ApiResponseUtil.success(SUCCESS_UPDATE_USER_PLAN); } @Override @GetMapping("/nickname/check") - public ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임", required = true) @RequestParam String name) { + public ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임", required = true) @RequestParam String name) { val response = MemberNameResponse.from(memberService.checkDuplicatedName(name)); return ApiResponseUtil.success(SUCCESS_CHECK_DUPLICATED_NAME, response); } @Override @PatchMapping("/push") - public ResponseEntity> updateUserPush(Principal principal, @RequestBody MemberPushUpdateRequest request) { + public ResponseEntity> updateUserPush(Principal principal, @RequestBody MemberPushUpdateRequest request) { memberService.updateHasAlarm(Util.getMemberId(principal), MemberPushUpdateServiceRequest.of(request)); return ApiResponseUtil.success(SUCCESS_UPDATE_USER_PUSH); } diff --git a/smeem-api/src/main/java/com/smeem/api/test/api/TestApi.java b/smeem-api/src/main/java/com/smeem/api/test/api/TestApi.java index a0af99d1..a9e41cc7 100644 --- a/smeem-api/src/main/java/com/smeem/api/test/api/TestApi.java +++ b/smeem-api/src/main/java/com/smeem/api/test/api/TestApi.java @@ -1,6 +1,6 @@ package com.smeem.api.test.api; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,7 +21,7 @@ public interface TestApi { @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> test(); + ResponseEntity> test(); @Operation(summary = "푸시알림 테스트 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @@ -31,5 +31,5 @@ public interface TestApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> alarmTest(Principal principal); + ResponseEntity> alarmTest(Principal principal); } diff --git a/smeem-api/src/main/java/com/smeem/api/test/api/TestApiController.java b/smeem-api/src/main/java/com/smeem/api/test/api/TestApiController.java index a08c9276..ef269a45 100644 --- a/smeem-api/src/main/java/com/smeem/api/test/api/TestApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/test/api/TestApiController.java @@ -3,7 +3,7 @@ import java.security.Principal; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.test.service.TestService; import com.smeem.api.test.service.dto.request.TestPushAlarmServiceRequest; import com.smeem.common.util.Util; @@ -26,12 +26,12 @@ public class TestApiController implements TestApi { private final TestService testService; @GetMapping - public ResponseEntity> test() { + public ResponseEntity> test() { return ApiResponseUtil.success(SUCCESS_SERVER_CONNECT); } @GetMapping("/alarm") - public ResponseEntity> alarmTest(Principal principal) { + public ResponseEntity> alarmTest(Principal principal) { val memberId = Util.getMemberId(principal); testService.pushTest(TestPushAlarmServiceRequest.of(memberId)); return ApiResponseUtil.success(SUCCESS_SEND_PUSH_ALARM); diff --git a/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java b/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java index 84351294..fd1318f4 100644 --- a/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java +++ b/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java @@ -1,6 +1,6 @@ package com.smeem.api.topic.api; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -21,5 +21,5 @@ public interface TopicApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getTopicByRandom(); + ResponseEntity> getTopicByRandom(); } diff --git a/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApiController.java b/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApiController.java index 9a779a44..149e2513 100644 --- a/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApiController.java @@ -1,7 +1,7 @@ package com.smeem.api.topic.api; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.topic.api.dto.response.RandomTopicGetResponse; import com.smeem.api.topic.service.TopicService; import lombok.val; @@ -22,7 +22,7 @@ public class TopicApiController implements TopicApi { private final TopicService topicService; @GetMapping("/random") - public ResponseEntity> getTopicByRandom() { + public ResponseEntity> getTopicByRandom() { val response = RandomTopicGetResponse.from(topicService.getTopicByRandom()); return ApiResponseUtil.success(SUCCESS_GET_RANDOM_TOPIC, response); } diff --git a/smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java b/smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java index 02199143..269d9705 100644 --- a/smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java +++ b/smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java @@ -1,6 +1,6 @@ package com.smeem.api.version.api; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; @@ -15,5 +15,5 @@ public interface VersionApi { @ApiResponse(responseCode = "200", description = "성공"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getClientVersion(); + ResponseEntity> getClientVersion(); } diff --git a/smeem-api/src/main/java/com/smeem/api/version/api/VersionApiController.java b/smeem-api/src/main/java/com/smeem/api/version/api/VersionApiController.java index 112c5f0f..bb4e2d5e 100644 --- a/smeem-api/src/main/java/com/smeem/api/version/api/VersionApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/version/api/VersionApiController.java @@ -1,7 +1,7 @@ package com.smeem.api.version.api; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.BaseResponse; +import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.version.api.dto.response.ClientVersionGetResponse; import com.smeem.api.version.service.VersionService; import lombok.RequiredArgsConstructor; @@ -21,7 +21,7 @@ public class VersionApiController implements VersionApi { private final VersionService versionService; @GetMapping("/client/app") - public ResponseEntity> getClientVersion() { + public ResponseEntity> getClientVersion() { val response = ClientVersionGetResponse.of(versionService.getClientVersion()); return ApiResponseUtil.success(SUCCESS_GET_APP_VERSION, response); } diff --git a/smeem-api/src/test/java/com/smeem/api/controller/DiaryControllerTest.java b/smeem-api/src/test/java/com/smeem/api/controller/DiaryControllerTest.java index 0be52f44..0e97b40e 100644 --- a/smeem-api/src/test/java/com/smeem/api/controller/DiaryControllerTest.java +++ b/smeem-api/src/test/java/com/smeem/api/controller/DiaryControllerTest.java @@ -3,7 +3,7 @@ //import com.epages.restdocs.apispec.ResourceSnippetParameters; //import com.smeem.api.badge.controller.dto.response.AcquiredBadgeResponse; //import com.smeem.api.common.ApiResponseUtil; -//import com.smeem.api.common.BaseResponse; +//import com.smeem.api.common.dto.BaseResponse; //import com.smeem.api.diary.controller.DiaryController; //import com.smeem.api.diary.api.dto.request.DiaryCreateRequest; //import com.smeem.api.diary.api.dto.request.DiaryModifyRequest; From b783dae25ddd606f82da8683749360ecbcb0a8e8 Mon Sep 17 00:00:00 2001 From: thguss Date: Wed, 20 Mar 2024 16:28:14 +0900 Subject: [PATCH 05/11] =?UTF-8?q?[FIX]=20=EC=9D=91=EB=8B=B5=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20FailureResponse=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/common/advicer/ErrorHandler.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/smeem-api/src/main/java/com/smeem/api/common/advicer/ErrorHandler.java b/smeem-api/src/main/java/com/smeem/api/common/advicer/ErrorHandler.java index 59bc0870..f36bbdd9 100644 --- a/smeem-api/src/main/java/com/smeem/api/common/advicer/ErrorHandler.java +++ b/smeem-api/src/main/java/com/smeem/api/common/advicer/ErrorHandler.java @@ -1,7 +1,7 @@ package com.smeem.api.common.advicer; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.dto.SuccessResponse; +import com.smeem.api.common.dto.FailureResponse; import com.smeem.common.exception.*; import com.smeem.external.discord.DiscordAlarmSender; import lombok.RequiredArgsConstructor; @@ -19,57 +19,57 @@ public class ErrorHandler { private final DiscordAlarmSender discordAlarmSender; @ExceptionHandler(TrainingTimeException.class) - public ResponseEntity> trainingTimeException(TrainingTimeException exception) { + public ResponseEntity trainingTimeException(TrainingTimeException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(TokenException.class) - public ResponseEntity> tokenException(TokenException exception) { + public ResponseEntity tokenException(TokenException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(BadgeException.class) - public ResponseEntity> badgeException(BadgeException exception) { + public ResponseEntity badgeException(BadgeException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(DiaryException.class) - public ResponseEntity> diaryException(DiaryException exception) { + public ResponseEntity diaryException(DiaryException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(MemberException.class) - public ResponseEntity> memberException(MemberException exception) { + public ResponseEntity memberException(MemberException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(GoalException.class) - public ResponseEntity> goalException(GoalException exception) { + public ResponseEntity goalException(GoalException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(TopicException.class) - public ResponseEntity> topicException(TopicException exception) { + public ResponseEntity topicException(TopicException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(AppleException.class) - public ResponseEntity> appleException(AppleException exception) { + public ResponseEntity appleException(AppleException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(FcmException.class) - public ResponseEntity> fcmException(FcmException exception) { + public ResponseEntity fcmException(FcmException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(AuthException.class) - public ResponseEntity> authException(AuthException exception) { + public ResponseEntity authException(AuthException exception) { return ApiResponseUtil.failure(exception.getFailureCode()); } @ExceptionHandler(RuntimeException.class) - public ResponseEntity> baseException(RuntimeException exception) { + public ResponseEntity baseException(RuntimeException exception) { sendDiscordAlarm(exception); return ApiResponseUtil.failure(SERVER_ERROR); } From 4ec62263f3b2432ccc534bf1b735fc77cdf5dc0c Mon Sep 17 00:00:00 2001 From: thguss Date: Wed, 20 Mar 2024 16:35:02 +0900 Subject: [PATCH 06/11] =?UTF-8?q?[ADD]=20=EC=9D=91=EB=8B=B5=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80,?= =?UTF-8?q?=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=84=A4=EB=AA=85=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/smeem/api/diary/api/DiaryApi.java | 101 +++++++++++++++--- .../api/diary/api/DiaryApiController.java | 6 +- .../java/com/smeem/api/goal/api/GoalApi.java | 33 ++++-- .../smeem/api/goal/api/GoalApiController.java | 4 +- .../com/smeem/api/topic/api/TopicApi.java | 24 ++++- .../api/topic/api/TopicApiController.java | 2 +- .../com/smeem/api/version/api/VersionApi.java | 12 ++- .../api/version/api/VersionApiController.java | 2 +- 8 files changed, 148 insertions(+), 36 deletions(-) diff --git a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java index c4d805a2..ecab02e2 100644 --- a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java +++ b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApi.java @@ -1,12 +1,16 @@ package com.smeem.api.diary.api; +import com.smeem.api.common.dto.FailureResponse; import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.diary.api.dto.request.DiaryCreateRequest; import com.smeem.api.diary.api.dto.request.DiaryModifyRequest; +import com.smeem.api.diary.api.dto.response.DiaryCreateResponse; import com.smeem.api.diary.api.dto.response.DiaryGetResponse; +import com.smeem.api.diary.api.dto.response.DiaryListGetResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -26,19 +30,46 @@ public interface DiaryApi { @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "401", + description = "유효하지 않은 토큰", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) - ResponseEntity> createDiary(Principal principal, @RequestBody DiaryCreateRequest request); + ResponseEntity> createDiary( + Principal principal, + @RequestBody DiaryCreateRequest request + ); @Operation(summary = "일기 상세 조회 API") @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청", content = @Content), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰", content = @Content), - @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content) + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "401", + description = "유효하지 않은 토큰", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) ResponseEntity> getDiaryDetail(@PathVariable long diaryId); @@ -46,9 +77,21 @@ public interface DiaryApi { @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "401", + description = "유효하지 않은 토큰", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) ResponseEntity> modifyDiary(@PathVariable long diaryId, @RequestBody DiaryModifyRequest request); @@ -56,9 +99,21 @@ public interface DiaryApi { @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "401", + description = "유효하지 않은 토큰", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) ResponseEntity> deleteDiary(@PathVariable long diaryId); @@ -66,11 +121,23 @@ public interface DiaryApi { @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "401", + description = "유효하지 않은 토큰", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) - ResponseEntity> getDiaries( + ResponseEntity> getDiaries( Principal principal, @RequestParam String start, @RequestParam String end diff --git a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java index 75190f61..7a8df23b 100644 --- a/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/diary/api/DiaryApiController.java @@ -39,7 +39,7 @@ public class DiaryApiController implements DiaryApi { private final DiaryQueryService diaryQueryService; @PostMapping - public ResponseEntity> createDiary(Principal principal, @RequestBody DiaryCreateRequest request) { + public ResponseEntity> createDiary(Principal principal, @RequestBody DiaryCreateRequest request) { val memberId = Util.getMemberId(principal); val response = DiaryCreateResponse.from( diaryCommandService.createDiary(DiaryCreateServiceRequest.of(memberId, request))); @@ -51,7 +51,7 @@ public ResponseEntity> createDiary(Principal principal, @Requ public ResponseEntity> getDiaryDetail(@PathVariable long diaryId) { val response = DiaryGetResponse.from( diaryQueryService.getDiaryDetail(DiaryGetServiceRequest.of(diaryId))); - return ApiResponseUtil.successTest(SUCCESS_GET_DIARY, response); + return ApiResponseUtil.success(SUCCESS_GET_DIARY, response); } @PatchMapping("/{diaryId}") @@ -67,7 +67,7 @@ public ResponseEntity> deleteDiary(@PathVariable long diaryId } @GetMapping - public ResponseEntity> getDiaries( + public ResponseEntity> getDiaries( Principal principal, @RequestParam String start, @RequestParam String end diff --git a/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java b/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java index 2a38b006..5712b295 100644 --- a/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java +++ b/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApi.java @@ -1,8 +1,13 @@ package com.smeem.api.goal.api; +import com.smeem.api.common.dto.FailureResponse; import com.smeem.api.common.dto.SuccessResponse; +import com.smeem.api.goal.api.dto.response.GoalGetResponse; +import com.smeem.api.goal.api.dto.response.GoalListGetResponse; import com.smeem.domain.goal.model.GoalType; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -15,16 +20,32 @@ public interface GoalApi { @Operation(summary = "목표 전체 목록 조회 API") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) - ResponseEntity> getAllGoals(); + ResponseEntity> getAllGoals(); @Operation(summary = "목표 상세 조회 API") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) - ResponseEntity> getGoalByType(@PathVariable GoalType type); + ResponseEntity> getGoalByType(@PathVariable GoalType type); } diff --git a/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApiController.java b/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApiController.java index 4cf07890..109fbb0c 100644 --- a/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/goal/api/GoalApiController.java @@ -28,13 +28,13 @@ public class GoalApiController implements GoalApi { private final GoalService goalService; @GetMapping - public ResponseEntity> getAllGoals() { + public ResponseEntity> getAllGoals() { val response = GoalListGetResponse.from(goalService.getAllGoals()); return ApiResponseUtil.success(SUCCESS_GET_GOALS, response); } @GetMapping("/{type}") - public ResponseEntity> getGoalByType(@PathVariable GoalType type) { + public ResponseEntity> getGoalByType(@PathVariable GoalType type) { val response = GoalGetResponse.from(goalService.getByType(GoalGetServiceRequest.of(type))); return ApiResponseUtil.success(SUCCESS_GET_GOAL, response); } diff --git a/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java b/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java index fd1318f4..063815c3 100644 --- a/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java +++ b/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApi.java @@ -1,8 +1,12 @@ package com.smeem.api.topic.api; +import com.smeem.api.common.dto.FailureResponse; import com.smeem.api.common.dto.SuccessResponse; +import com.smeem.api.topic.api.dto.response.RandomTopicGetResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -17,9 +21,21 @@ public interface TopicApi { @Parameter(name = "Authorization", description = "Bearer ${Smeem Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "4xx", + description = "유효하지 않은 요청", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "401", + description = "유효하지 않은 토큰", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ), + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) - ResponseEntity> getTopicByRandom(); + ResponseEntity> getTopicByRandom(); } diff --git a/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApiController.java b/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApiController.java index 149e2513..a68221fa 100644 --- a/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/topic/api/TopicApiController.java @@ -22,7 +22,7 @@ public class TopicApiController implements TopicApi { private final TopicService topicService; @GetMapping("/random") - public ResponseEntity> getTopicByRandom() { + public ResponseEntity> getTopicByRandom() { val response = RandomTopicGetResponse.from(topicService.getTopicByRandom()); return ApiResponseUtil.success(SUCCESS_GET_RANDOM_TOPIC, response); } diff --git a/smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java b/smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java index 269d9705..ea4bb764 100644 --- a/smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java +++ b/smeem-api/src/main/java/com/smeem/api/version/api/VersionApi.java @@ -1,7 +1,11 @@ package com.smeem.api.version.api; +import com.smeem.api.common.dto.FailureResponse; import com.smeem.api.common.dto.SuccessResponse; +import com.smeem.api.version.api.dto.response.ClientVersionGetResponse; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -13,7 +17,11 @@ public interface VersionApi { @Operation(summary = "클라이언트 앱 버전 조회 API") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse( + responseCode = "500", + description = "서버 내부 오류", + content = @Content(schema = @Schema(implementation = FailureResponse.class)) + ) }) - ResponseEntity> getClientVersion(); + ResponseEntity> getClientVersion(); } diff --git a/smeem-api/src/main/java/com/smeem/api/version/api/VersionApiController.java b/smeem-api/src/main/java/com/smeem/api/version/api/VersionApiController.java index bb4e2d5e..3fafd8cb 100644 --- a/smeem-api/src/main/java/com/smeem/api/version/api/VersionApiController.java +++ b/smeem-api/src/main/java/com/smeem/api/version/api/VersionApiController.java @@ -21,7 +21,7 @@ public class VersionApiController implements VersionApi { private final VersionService versionService; @GetMapping("/client/app") - public ResponseEntity> getClientVersion() { + public ResponseEntity> getClientVersion() { val response = ClientVersionGetResponse.of(versionService.getClientVersion()); return ApiResponseUtil.success(SUCCESS_GET_APP_VERSION, response); } From b7d3907369165bfb33296f0409fa21802b28da12 Mon Sep 17 00:00:00 2001 From: unanchoi Date: Wed, 20 Mar 2024 22:24:46 +0900 Subject: [PATCH 07/11] =?UTF-8?q?[CHORE]=20AuthApi=20Response=20DTO?= =?UTF-8?q?=EB=A1=9C=20=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java | 6 ++++-- .../main/java/com/smeem/api/auth/api/AuthController.java | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java index 79d39674..0508fd77 100644 --- a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java +++ b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java @@ -1,6 +1,8 @@ package com.smeem.api.auth.api; import com.smeem.api.auth.api.dto.request.SignInRequest; +import com.smeem.api.auth.api.dto.response.SignInResponse; +import com.smeem.api.auth.api.dto.response.token.TokenResponse; import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -28,7 +30,7 @@ public interface AuthApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException; + ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException; @Operation(summary = "토큰 재발급 API") @Parameter(name = "Authorization", description = "Bearer ${Smeme Refresh Token}", in = HEADER, required = true) @@ -37,7 +39,7 @@ public interface AuthApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> reissueToken(Principal principal); + ResponseEntity> reissueToken(Principal principal); @Operation(summary = "사용자 로그아웃 API") diff --git a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthController.java b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthController.java index e13fb133..ea924e8e 100644 --- a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthController.java +++ b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthController.java @@ -31,15 +31,15 @@ public class AuthController implements AuthApi { @Override @PostMapping - public ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, - @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException { + public ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, + @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException { val response = SignInResponse.from(authService.signIn(socialAccessToken, SignInServiceRequest.of(request))); return ApiResponseUtil.success(SUCCESS_SIGNIN, response); } @Override @PostMapping("/token") - public ResponseEntity> reissueToken(Principal principal) { + public ResponseEntity> reissueToken(Principal principal) { val response = TokenResponse.from(tokenService.issueToken(Util.getMemberId(principal))); return ApiResponseUtil.success(SUCCESS_ISSUE_TOKEN, response); } From 7b27d85d76f137be1bdb3e77aa1ed519b341c8b0 Mon Sep 17 00:00:00 2001 From: unanchoi Date: Wed, 20 Mar 2024 22:31:33 +0900 Subject: [PATCH 08/11] =?UTF-8?q?[CHORE]=20BadgeApi=20Response=20DTO=20?= =?UTF-8?q?=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java | 3 ++- .../src/main/java/com/smeem/api/badge/api/BadgeController.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java index 159a55a3..ef5c5af6 100644 --- a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java +++ b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java @@ -1,5 +1,6 @@ package com.smeem.api.badge.api; +import com.smeem.api.badge.api.dto.response.BadgeListResponse; import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -23,6 +24,6 @@ public interface BadgeApi { @ApiResponse(responseCode = "4011", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getBadges(Principal principal); + ResponseEntity> getBadges(Principal principal); } diff --git a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeController.java b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeController.java index ee17d51c..c097dc94 100644 --- a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeController.java +++ b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeController.java @@ -25,7 +25,7 @@ public class BadgeController implements BadgeApi { @Override @GetMapping - public ResponseEntity> getBadges(Principal principal) { + public ResponseEntity> getBadges(Principal principal) { val response = BadgeListResponse.from(badgeService.getBadges(Util.getMemberId(principal))); return ApiResponseUtil.success(SUCCESS_GET_BADGES, response); } From 2979310abe6d5eccbb462840fa2fee9354d7d967 Mon Sep 17 00:00:00 2001 From: unanchoi Date: Wed, 20 Mar 2024 22:31:49 +0900 Subject: [PATCH 09/11] =?UTF-8?q?[CHORE]=20MemberApi=20Response=20DTO=20?= =?UTF-8?q?=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/smeem/api/member/api/MemberApi.java | 9 ++++++--- .../java/com/smeem/api/member/api/MemberController.java | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java b/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java index 9f0d7959..db20d7a7 100644 --- a/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java +++ b/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java @@ -4,6 +4,9 @@ import com.smeem.api.member.api.dto.request.MemberPlanUpdateRequest; import com.smeem.api.member.api.dto.request.MemberPushUpdateRequest; import com.smeem.api.member.api.dto.request.MemberUpdateRequest; +import com.smeem.api.member.api.dto.response.MemberGetResponse; +import com.smeem.api.member.api.dto.response.MemberNameResponse; +import com.smeem.api.member.api.dto.response.MemberUpdateResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -28,7 +31,7 @@ public interface MemberApi { @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), @ApiResponse(responseCode = "500", description = "서버 오류") }) - ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request); + ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request); @Operation(summary = "사용자 프로필 조회 API") @@ -38,7 +41,7 @@ public interface MemberApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> getProfile(Principal principal); + ResponseEntity> getProfile(Principal principal); @Operation(summary = "사용자 학습 계획 수정 API") @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @@ -57,7 +60,7 @@ public interface MemberApi { @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), @ApiResponse(responseCode = "500", description = "서버 내부 오류") }) - ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임") @RequestParam String name); + ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임") @RequestParam String name); @Operation(summary = "사용자 학습 계획 수정 API") @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) diff --git a/smeem-api/src/main/java/com/smeem/api/member/api/MemberController.java b/smeem-api/src/main/java/com/smeem/api/member/api/MemberController.java index 0ee86eb6..78a0b4e7 100644 --- a/smeem-api/src/main/java/com/smeem/api/member/api/MemberController.java +++ b/smeem-api/src/main/java/com/smeem/api/member/api/MemberController.java @@ -33,7 +33,7 @@ public class MemberController implements MemberApi { @Override @PatchMapping - public ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request) { + public ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request) { val response = MemberUpdateResponse.from(memberService.updateUserProfile( Util.getMemberId(principal), MemberServiceUpdateUserProfileRequest.of(request))); @@ -42,7 +42,7 @@ public ResponseEntity> updateProfile(Principal principal, @Re @Override @GetMapping("/me") - public ResponseEntity> getProfile(Principal principal) { + public ResponseEntity> getProfile(Principal principal) { val response = MemberGetResponse.from(memberService.getMemberProfile(Util.getMemberId(principal))); return ApiResponseUtil.success(SUCCESS_GET_USER, response); } @@ -56,7 +56,7 @@ public ResponseEntity> updateUserPlan(Principal principal, @V @Override @GetMapping("/nickname/check") - public ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임", required = true) @RequestParam String name) { + public ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임", required = true) @RequestParam String name) { val response = MemberNameResponse.from(memberService.checkDuplicatedName(name)); return ApiResponseUtil.success(SUCCESS_CHECK_DUPLICATED_NAME, response); } From 4978b5ff856572a037bb3ec44d053ef0ef3afe0c Mon Sep 17 00:00:00 2001 From: unanchoi Date: Wed, 20 Mar 2024 22:40:52 +0900 Subject: [PATCH 10/11] =?UTF-8?q?[ADD]=20Swagger=20=EC=9D=91=EB=8B=B5=20?= =?UTF-8?q?=EC=84=A4=EB=AA=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/smeem/api/auth/api/AuthApi.java | 21 +++++++++------- .../com/smeem/api/badge/api/BadgeApi.java | 7 ++++-- .../com/smeem/api/member/api/MemberApi.java | 25 +++++++++++-------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java index 0508fd77..f556981e 100644 --- a/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java +++ b/smeem-api/src/main/java/com/smeem/api/auth/api/AuthApi.java @@ -3,9 +3,12 @@ import com.smeem.api.auth.api.dto.request.SignInRequest; import com.smeem.api.auth.api.dto.response.SignInResponse; import com.smeem.api.auth.api.dto.response.token.TokenResponse; +import com.smeem.api.common.dto.FailureResponse; import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -26,9 +29,9 @@ public interface AuthApi { @Parameter(name = "Authorization", description = "Bearer ${Social Platform Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "소셜로그인 성공"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> signIn(@RequestHeader("Authorization") final String socialAccessToken, @RequestBody SignInRequest request) throws NoSuchAlgorithmException, InvalidKeySpecException; @@ -36,8 +39,8 @@ public interface AuthApi { @Parameter(name = "Authorization", description = "Bearer ${Smeme Refresh Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "토큰 재발급 성공"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> reissueToken(Principal principal); @@ -46,8 +49,8 @@ public interface AuthApi { @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "로그아웃 성공"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> signOut(Principal principal); @@ -56,8 +59,8 @@ public interface AuthApi { @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "회원 탈퇴 성공"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> withDrawl(Principal principal); diff --git a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java index ef5c5af6..39e72911 100644 --- a/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java +++ b/smeem-api/src/main/java/com/smeem/api/badge/api/BadgeApi.java @@ -1,9 +1,12 @@ package com.smeem.api.badge.api; import com.smeem.api.badge.api.dto.response.BadgeListResponse; +import com.smeem.api.common.dto.FailureResponse; import com.smeem.api.common.dto.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -21,8 +24,8 @@ public interface BadgeApi { @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "뱃지 리스트 조회 성공"), - @ApiResponse(responseCode = "4011", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "4011", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> getBadges(Principal principal); diff --git a/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java b/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java index db20d7a7..a4a8a8a6 100644 --- a/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java +++ b/smeem-api/src/main/java/com/smeem/api/member/api/MemberApi.java @@ -1,5 +1,6 @@ package com.smeem.api.member.api; +import com.smeem.api.common.dto.FailureResponse; import com.smeem.api.common.dto.SuccessResponse; import com.smeem.api.member.api.dto.request.MemberPlanUpdateRequest; import com.smeem.api.member.api.dto.request.MemberPushUpdateRequest; @@ -9,6 +10,8 @@ import com.smeem.api.member.api.dto.response.MemberUpdateResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -27,9 +30,9 @@ public interface MemberApi { @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "회원 정보 조회 성공"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "500", description = "서버 오류") + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> updateProfile(Principal principal, @RequestBody MemberUpdateRequest request); @@ -38,8 +41,8 @@ public interface MemberApi { @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "회원 정보 조회 성공"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> getProfile(Principal principal); @@ -48,8 +51,8 @@ public interface MemberApi { @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "회원 학습 계획 업데이트 성공"), @ApiResponse(responseCode = "4xx", description = "유효하지 않은 요청"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> updateUserPlan(Principal principal, @Valid @RequestBody MemberPlanUpdateRequest request); @@ -57,8 +60,8 @@ public interface MemberApi { @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "닉네임 중복 검사 성공"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> checkDuplicatedName(@Parameter(description = "유저 닉네임") @RequestParam String name); @@ -66,8 +69,8 @@ public interface MemberApi { @Parameter(name = "Authorization", description = "Bearer ${Smeme Access Token}", in = HEADER, required = true) @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "회원 푸시알람 동의여부 업데이트 성공"), - @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다"), - @ApiResponse(responseCode = "500", description = "서버 내부 오류") + @ApiResponse(responseCode = "401", description = "유효하지 않은 토큰입니다", content = @Content(schema = @Schema(implementation = FailureResponse.class))), + @ApiResponse(responseCode = "500", description = "서버 내부 오류", content = @Content(schema = @Schema(implementation = FailureResponse.class))) }) ResponseEntity> updateUserPush(Principal principal, @RequestBody MemberPushUpdateRequest request); } From c1e583e2f9f90f72963058ed5a93449c1e1301bf Mon Sep 17 00:00:00 2001 From: thguss Date: Thu, 21 Mar 2024 04:58:37 +0900 Subject: [PATCH 11/11] =?UTF-8?q?[FIX]=20=EC=8B=A4=ED=8C=A8=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smeem-api/src/main/java/com/smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java b/smeem-api/src/main/java/com/smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java index ea7e25d4..c84715ea 100644 --- a/smeem-api/src/main/java/com/smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java +++ b/smeem-api/src/main/java/com/smeem/api/auth/jwt/CustomJwtAuthenticationEntryPoint.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.smeem.api.common.ApiResponseUtil; -import com.smeem.api.common.dto.SuccessResponse; +import com.smeem.api.common.dto.FailureResponse; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.springframework.http.MediaType; @@ -32,7 +32,7 @@ private void setResponse(HttpServletResponse response) throws IOException { response.getWriter().println(objectMapper.writeValueAsString(getFailureResponse())); } - private ResponseEntity> getFailureResponse() { + private ResponseEntity getFailureResponse() { return ApiResponseUtil.failure(INVALID_TOKEN); } }