diff --git a/src/main/java/com/diareat/diareat/util/api/ApiBody.java b/src/main/java/com/diareat/diareat/util/api/ApiBody.java deleted file mode 100644 index d4fca17..0000000 --- a/src/main/java/com/diareat/diareat/util/api/ApiBody.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.diareat.diareat.util.api; - -public class ApiBody { - - private final T data; - private final T msg; - - public ApiBody(T data, T msg) { - this.data = data; - this.msg = msg; - } - - public T getData() { - return data; - } -} diff --git a/src/main/java/com/diareat/diareat/util/api/ApiHeader.java b/src/main/java/com/diareat/diareat/util/api/ApiHeader.java index f6c4fb9..7788e9a 100644 --- a/src/main/java/com/diareat/diareat/util/api/ApiHeader.java +++ b/src/main/java/com/diareat/diareat/util/api/ApiHeader.java @@ -1,18 +1,15 @@ package com.diareat.diareat.util.api; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor public class ApiHeader { private int code; private String message; - public ApiHeader(int code, String message) { - this.code = code; - this.message = message; - } - - public ApiHeader() { - } - public int getCode() { return code; } diff --git a/src/main/java/com/diareat/diareat/util/api/ApiResponse.java b/src/main/java/com/diareat/diareat/util/api/ApiResponse.java index 4fe2374..ba96c5e 100644 --- a/src/main/java/com/diareat/diareat/util/api/ApiResponse.java +++ b/src/main/java/com/diareat/diareat/util/api/ApiResponse.java @@ -8,24 +8,22 @@ public class ApiResponse { private ApiHeader header; - private ApiBody body; + private T data; + private String msg; private static final int SUCCESS = 200; - public ApiResponse(ApiHeader header, ApiBody body) { - this.header = header; - this.body = body; - } - - public ApiResponse(ApiHeader header) { + private ApiResponse(ApiHeader header, T data, String msg) { this.header = header; + this.data = data; + this.msg = msg; } public static ApiResponse success(T data, String message) { - return new ApiResponse(new ApiHeader(SUCCESS, "SUCCESS"), new ApiBody(data, message)); + return new ApiResponse(new ApiHeader(SUCCESS, "SUCCESS"), data, message); } public static ApiResponse fail(ResponseCode responseCode) { - return new ApiResponse(new ApiHeader(responseCode.getHttpStatusCode(), responseCode.getMessage()), new ApiBody(null, responseCode.getMessage())); + return new ApiResponse(new ApiHeader(responseCode.getHttpStatusCode(), responseCode.getMessage()), null, responseCode.getMessage()); } } \ No newline at end of file