14
14
@ Getter
15
15
public class MultiResponse <T > extends Response {
16
16
17
- private long total ;
18
17
19
- private Collection <T > data ;
18
+ private Content <T > data ;
19
+
20
+ @ Setter
21
+ @ Getter
22
+ public static class Content <T >{
23
+ private long total ;
24
+ private Collection <T > list ;
25
+ }
20
26
21
27
public static <T > MultiResponse <T > of (Collection <T > data , long total ) {
22
28
MultiResponse <T > multiResponse = new MultiResponse <>();
23
29
multiResponse .setSuccess (true );
24
- multiResponse .setData (data );
25
- multiResponse .setTotal (total );
30
+ Content <T > content = new Content <>();
31
+ content .setTotal (total );
32
+ content .setList (data );
33
+ multiResponse .setData (content );
26
34
return multiResponse ;
27
35
}
28
36
@@ -36,20 +44,23 @@ public static <T> MultiResponse<T> empty() {
36
44
MultiResponse <T > multiResponse = new MultiResponse <>();
37
45
multiResponse .setSuccess (true );
38
46
multiResponse .setData (null );
39
- multiResponse .setTotal (0 );
47
+ Content <T > content = new Content <>();
48
+ content .setTotal (0 );
49
+ content .setList (null );
40
50
return multiResponse ;
41
51
}
42
52
43
53
44
54
public static <T > MultiResponse <T > of (Collection <T > data ) {
45
55
MultiResponse <T > multiResponse = new MultiResponse <>();
46
56
multiResponse .setSuccess (true );
47
- multiResponse .setData (data );
48
57
long total = 0 ;
49
58
if (data !=null ){
50
59
total = data .size ();
51
60
}
52
- multiResponse .setTotal (total );
61
+ Content <T > content = new Content <>();
62
+ content .setTotal (total );
63
+ content .setList (data );
53
64
return multiResponse ;
54
65
}
55
66
0 commit comments