-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResponseDto.java
More file actions
30 lines (25 loc) · 840 Bytes
/
ResponseDto.java
File metadata and controls
30 lines (25 loc) · 840 Bytes
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
package com.selab.todo.common.dto;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@Data
@RequiredArgsConstructor
public class ResponseDto<T> {
private final T data;
public static <T> ResponseEntity<ResponseDto<T>> ok(T data) {
var response = new ResponseDto<T>(data);
return ResponseEntity.ok(response);
}
public static <T> ResponseEntity<ResponseDto<T>> created(T data) {
var response = new ResponseDto<T>(data);
return ResponseEntity
.status(HttpStatus.CREATED)
.body(response);
}
public static ResponseEntity<Void> noContent() {
return ResponseEntity
.status(HttpStatus.NO_CONTENT)
.build();
}
}