File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
back/src/main/java/com/back/global/common Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .back .global .common ;
2+
3+ import com .fasterxml .jackson .annotation .JsonInclude ;
4+ import lombok .AllArgsConstructor ;
5+ import lombok .Getter ;
6+ import org .springframework .http .HttpStatus ;
7+
8+ /**
9+ * 공통 응답 형태
10+ * {
11+ * "data": { ... },
12+ * "message": "성공적으로 조회되었습니다.",
13+ * "status": 200
14+ * }
15+ */
16+ @ Getter
17+ @ JsonInclude (JsonInclude .Include .NON_NULL )
18+ public class ApiResponse <T > {
19+
20+ private final T data ;
21+ private final String message ;
22+ private final int status ;
23+
24+ private ApiResponse (T data , String message , int status ) {
25+ this .data = data ;
26+ this .message = message ;
27+ this .status = status ;
28+ }
29+
30+ public static <T > ApiResponse <T > success (T data , String message ) {
31+ return new ApiResponse <>(data , message , HttpStatus .OK .value ());
32+ }
33+
34+ public static <T > ApiResponse <T > success (T data , String message , HttpStatus status ) {
35+ return new ApiResponse <>(data , message , status .value ());
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments