Skip to content

Commit

Permalink
Merge pull request #68 from Team-Going/feature/62
Browse files Browse the repository at this point in the history
[feat] 클라이언트 요청 사항에 따른 API 공통 응답 스펙 변경
  • Loading branch information
SunwoongH authored Jan 11, 2024
2 parents 05dab60 + 5d73d46 commit f567487
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doorip-api/src/main/java/org/doorip/common/ApiResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
@Getter
public class ApiResponse<T> {
private final int status;
@JsonInclude(value = JsonInclude.Include.NON_NULL)
private final String code;
private final String message;
@JsonInclude(value = JsonInclude.Include.NON_NULL)
Expand All @@ -22,13 +21,15 @@ public class ApiResponse<T> {
public static ApiResponse<?> of(SuccessMessage successMessage) {
return builder()
.status(successMessage.getHttpStatus().value())
.code(successMessage.getCode())
.message(successMessage.getMessage())
.build();
}

public static <T> ApiResponse<?> of(SuccessMessage successMessage, T data) {
return builder()
.status(successMessage.getHttpStatus().value())
.code(successMessage.getCode())
.message(successMessage.getMessage())
.data(data)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ public enum SuccessMessage {
/**
* 200 Ok
*/
OK(HttpStatus.OK, "요청이 성공했습니다."),
OK(HttpStatus.OK, "s2000", "요청이 성공했습니다."),

/**
* 201 Created
*/
CREATED(HttpStatus.CREATED, "요청이 성공했습니다.");
CREATED(HttpStatus.CREATED, "s2010", "요청이 성공했습니다.");

private final HttpStatus httpStatus;
private final String code;
private final String message;
}

0 comments on commit f567487

Please sign in to comment.