Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.pinHouse.server.core.response.response;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.micrometer.common.lang.Nullable;
import org.springframework.http.HttpStatus;

Expand All @@ -9,7 +10,7 @@
/**
* API 응답을 표준화하기 위한 레코드 클래스입니다.
*/

@JsonInclude(JsonInclude.Include.NON_NULL)
public record ApiResponse<T>(
@JsonIgnore
HttpStatus httpStatus,
Expand All @@ -30,6 +31,11 @@ public static <T> ApiResponse<T> created() {
return new ApiResponse<>(HttpStatus.CREATED, true, HttpStatus.CREATED.value(), "성공적으로 생성되었습니다.", null, null);
}

// 수정 성공 응답 (204 No Content)
public static <T> ApiResponse<T> updated() {
return new ApiResponse<>(HttpStatus.NO_CONTENT, true, HttpStatus.NO_CONTENT.value(), "성공적으로 수정되었습니다.", null, null);
}

// 삭제 성공 응답 (204 No Content)
public static <T> ApiResponse<T> deleted() {
return new ApiResponse<>(HttpStatus.NO_CONTENT, true, HttpStatus.NO_CONTENT.value(), "성공적으로 삭제 되었습니다.", null, null);
Expand All @@ -39,5 +45,5 @@ public static <T> ApiResponse<T> deleted() {
public static <T> ApiResponse<T> fail(final CustomException e) {
return new ApiResponse<>(e.getErrorCode().getHttpStatus(), false, e.getErrorCode().getCode(), e.getErrorCode().getMessage(), null, e.getFieldErrorResponses());
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.pinHouse.server.core.response.response.pageable;

import lombok.Builder;
import org.springframework.data.domain.Slice;

import java.util.List;

@Builder
public record SliceResponse<T>(
List<T> content,
boolean hasNext,
int page,
int size
) {
public static <T> SliceResponse<T> from(Slice<T> slice) {
return SliceResponse.<T>builder()
.content(slice.getContent())
.hasNext(slice.hasNext())
.page(slice.getNumber() + 1)
.size(slice.getSize())
.build();
}
}
Loading