Skip to content

Commit

Permalink
#3 fix: BaseResponse 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
sojungpp committed Dec 8, 2023
1 parent 6b99e56 commit 6003fd6
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.lang.Nullable;

@Getter
@RequiredArgsConstructor
Expand All @@ -14,14 +15,20 @@ public class BaseResponse<T> {
private final String message;
private T data;

public static BaseResponse OK(BaseResponseCode baseResponseCode) {
public static BaseResponse OK() {
BaseResponseCode baseResponseCode = BaseResponseCode.SUCCESS;
return new BaseResponse<>(baseResponseCode.getStatus().value(), baseResponseCode.getCode(), baseResponseCode.getMessage());
}

public static <T> BaseResponse<T> OK(BaseResponseCode baseResponseCode, T data) {
return new BaseResponse<T>(baseResponseCode.getStatus().value(), baseResponseCode.getCode(), baseResponseCode.getMessage(), data);
}

public static <T> BaseResponse<T> OK(@Nullable T data) {
BaseResponseCode baseResponseCode = BaseResponseCode.SUCCESS;
return new BaseResponse<T>(baseResponseCode.getStatus().value(), baseResponseCode.getCode(), baseResponseCode.getMessage(), data);
}

public static BaseResponse error(BaseResponseCode baseResponseCode, String message) {
return new BaseResponse<>(baseResponseCode.getStatus().value(), baseResponseCode.getCode(), baseResponseCode.getMessage());
}
Expand Down

0 comments on commit 6003fd6

Please sign in to comment.