ErrorCode 변경
This commit is contained in:
parent
b16008c0d1
commit
ea50617980
@ -14,11 +14,12 @@
|
|||||||
*************************************************************/
|
*************************************************************/
|
||||||
package io.company.localhost.common.dto;
|
package io.company.localhost.common.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
public class ApiResponse<T> {
|
public class ApiResponse<T> {
|
||||||
private int code;
|
private int code;
|
||||||
private HttpStatus status;
|
private HttpStatus status;
|
||||||
@ -47,6 +48,11 @@ public class ApiResponse<T> {
|
|||||||
public static <T> ApiResponse<T> error(HttpStatus status, String message) {
|
public static <T> ApiResponse<T> error(HttpStatus status, String message) {
|
||||||
return new ApiResponse<>(status, message, null);
|
return new ApiResponse<>(status, message, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> ApiResponse<T> error(int code,HttpStatus status, String message) {
|
||||||
|
return new ApiResponse<>(code,status, message, null);
|
||||||
|
}
|
||||||
|
|
||||||
public static <T> ApiResponse<T> okMessage(String message) {
|
public static <T> ApiResponse<T> okMessage(String message) {
|
||||||
return new ApiResponse<>(HttpStatus.OK, message, null);
|
return new ApiResponse<>(HttpStatus.OK, message, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,8 +43,12 @@ public enum UserErrorCode implements ErrorCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ApiResponse<?> getApiResponse() {
|
public ApiResponse<?> getApiResponse() {
|
||||||
|
if(this.code > 10000){
|
||||||
|
return ApiResponse.error((int) this.getCode(),this.getHttpStatus() , this.getMessage());
|
||||||
|
}else{
|
||||||
return ApiResponse.error(this.getHttpStatus() , this.getMessage());
|
return ApiResponse.error(this.getHttpStatus() , this.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ApiResponse<?> getApiResponse(String message) {
|
public ApiResponse<?> getApiResponse(String message) {
|
||||||
return ApiResponse.error(this.getHttpStatus() , message);
|
return ApiResponse.error(this.getHttpStatus() , message);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user