Skip to content

Commit ceb4acc

Browse files
committed
add MapResponse
1 parent 9aef55a commit ceb4acc

File tree

1 file changed

+36
-0
lines changed
  • springboot-starter/src/main/java/com/codingapi/springboot/framework/dto/response

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.codingapi.springboot.framework.dto.response;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
9+
@Setter
10+
@Getter
11+
public class MapResponse extends Response{
12+
13+
private Map<String,Object> data;
14+
15+
public MapResponse() {
16+
this.data = new HashMap<>();
17+
}
18+
19+
public static MapResponse create() {
20+
MapResponse singleResponse = new MapResponse();
21+
singleResponse.setSuccess(true);
22+
return singleResponse;
23+
}
24+
25+
public static MapResponse empty() {
26+
MapResponse mapResponse = new MapResponse();
27+
mapResponse.setSuccess(true);
28+
mapResponse.setData(null);
29+
return mapResponse;
30+
}
31+
32+
public MapResponse add(String key, Object value){
33+
this.data.put(key, value);
34+
return this;
35+
}
36+
}

0 commit comments

Comments
 (0)