diff --git a/src/main/java/io/company/localhost/common/dto/ApiResponse.java b/src/main/java/io/company/localhost/common/dto/ApiResponse.java index 8919aa2..fc3abe5 100644 --- a/src/main/java/io/company/localhost/common/dto/ApiResponse.java +++ b/src/main/java/io/company/localhost/common/dto/ApiResponse.java @@ -14,11 +14,12 @@ *************************************************************/ package io.company.localhost.common.dto; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.springframework.http.HttpStatus; -import lombok.Getter; - @Getter +@AllArgsConstructor public class ApiResponse { private int code; private HttpStatus status; @@ -47,6 +48,11 @@ public class ApiResponse { public static ApiResponse error(HttpStatus status, String message) { return new ApiResponse<>(status, message, null); } + + public static ApiResponse error(int code,HttpStatus status, String message) { + return new ApiResponse<>(code,status, message, null); + } + public static ApiResponse okMessage(String message) { return new ApiResponse<>(HttpStatus.OK, message, null); } diff --git a/src/main/java/io/company/localhost/common/exception/code/UserErrorCode.java b/src/main/java/io/company/localhost/common/exception/code/UserErrorCode.java index 42cd8c8..086d3b2 100644 --- a/src/main/java/io/company/localhost/common/exception/code/UserErrorCode.java +++ b/src/main/java/io/company/localhost/common/exception/code/UserErrorCode.java @@ -43,7 +43,11 @@ public enum UserErrorCode implements ErrorCode { } public ApiResponse getApiResponse() { - return ApiResponse.error(this.getHttpStatus() , this.getMessage()); + if(this.code > 10000){ + return ApiResponse.error((int) this.getCode(),this.getHttpStatus() , this.getMessage()); + }else{ + return ApiResponse.error(this.getHttpStatus() , this.getMessage()); + } } public ApiResponse getApiResponse(String message) {