-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathBaseResponse.java
More file actions
39 lines (34 loc) · 1.03 KB
/
BaseResponse.java
File metadata and controls
39 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package org.programmers.VoucherManagement.global.response;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import lombok.AllArgsConstructor;
import lombok.Getter;
import static org.programmers.VoucherManagement.global.response.SuccessCode.SUCCESS;
@Getter
@AllArgsConstructor
@JsonPropertyOrder({"code", "message", "result"})
public class BaseResponse<T> {
private final String message;
private final String code;
@JsonInclude(JsonInclude.Include.NON_NULL)
private T result;
/**
* 요청에 성공하고 반환값이 있는 경우
*
* @param result
*/
public BaseResponse(T result) {
this.message = SUCCESS.getMessage();
this.code = SUCCESS.getCode();
this.result = result;
}
/**
* 요청에 성공하고 반환값이 없는 경우
*
* @param status
*/
public BaseResponse(SuccessCode status) {
this.message = status.getMessage();
this.code = status.getCode();
}
}