-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
10 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/main/java/com/SollutionChallenge/HighLight/common/ApiBody.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.SollutionChallenge.HighLight.common; | ||
|
||
public class ApiBody <T>{ | ||
private T data; | ||
private T msg; | ||
|
||
public ApiBody(T data, T msg){ | ||
this.data = data; | ||
this.msg = msg; | ||
} | ||
|
||
public T getData(){ | ||
return data; | ||
} | ||
public T getMsg(){ | ||
return msg; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/SollutionChallenge/HighLight/common/ApiHeader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.SollutionChallenge.HighLight.common; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public class ApiHeader { | ||
private HttpStatus status; | ||
private String message; | ||
|
||
public ApiHeader(HttpStatus status, String message) { | ||
this.status = status; | ||
this.message = message; | ||
} | ||
|
||
public HttpStatus getStatus() { | ||
return status; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
} |
39 changes: 29 additions & 10 deletions
39
src/main/java/com/SollutionChallenge/HighLight/common/ApiResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,43 @@ | ||
package com.SollutionChallenge.HighLight.common; | ||
|
||
import com.SollutionChallenge.HighLight.Folder.FolderResponseDto; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ApiResponse<T> { | ||
private int status; | ||
private T data; | ||
private String message; | ||
|
||
private ApiResponse(int status, String message, T data) { | ||
this.status = status; | ||
this.data = data; | ||
this.message = message; | ||
private ApiHeader header; | ||
private ApiBody body; | ||
private static int SUCCESS =200; | ||
|
||
// private int status; | ||
// private T data; | ||
// private String message; | ||
|
||
// private ApiResponse(int status, String message, T data) { | ||
// this.status = status; | ||
// this.data = data; | ||
// this.message = message; | ||
// } | ||
|
||
private ApiResponse(ApiHeader header, ApiBody body){ | ||
this.header = header; | ||
this.body=body; | ||
} | ||
|
||
public static <T> ApiResponse<T> successCode(Success success, T data){ | ||
return new ApiResponse<>(success.getStatus().value(), success.getMessage(),null); | ||
public ApiResponse(ApiHeader header){ | ||
this.header = header; | ||
} | ||
|
||
// public static <T> ApiResponse<T> successCode(Success success, T data){ | ||
// return new ApiResponse<>(success.getStatus().value(), success.getMessage(),null); | ||
// } | ||
|
||
public static <T> ApiResponse<T> successCode(Success success, FolderResponseDto response){ | ||
return new ApiResponse<T>(new ApiHeader(success.getStatus(), success.getMessage()), new ApiBody(null, success.getMessage())); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters