commit | author | age
|
a18bfa
|
1 |
package com.changhong.autoform.entity.system; |
Z |
2 |
|
|
3 |
import com.changhong.autoform.constant.system.ErrCode; |
|
4 |
|
|
5 |
/** |
|
6 |
* API接口返回格式类 |
|
7 |
* @author yangrx |
|
8 |
* |
|
9 |
*/ |
|
10 |
public class RestResultGenerator implements ErrCode{ |
|
11 |
|
|
12 |
/** |
|
13 |
* normal |
|
14 |
* @param rspCode |
|
15 |
* @param data |
|
16 |
* @param message |
|
17 |
* @param <T> |
|
18 |
* @return |
|
19 |
*/ |
|
20 |
private static <T> RestResult<T> genResult(String rspCode, T data) { |
|
21 |
RestResult<T> result = RestResult.newInstance(); |
|
22 |
result.setRspCode(rspCode); |
|
23 |
result.setData(data); |
|
24 |
return result; |
|
25 |
} |
|
26 |
|
|
27 |
/** |
|
28 |
* success |
|
29 |
* |
|
30 |
* @param data |
|
31 |
* @param <T> |
|
32 |
* @return |
|
33 |
*/ |
|
34 |
public static <T> RestResult<T> ok(T data) { |
|
35 |
return genResult(SUCCESS, data); |
|
36 |
} |
|
37 |
|
|
38 |
/** |
|
39 |
* success |
|
40 |
* @param data |
|
41 |
* @param <T> |
|
42 |
* @return |
|
43 |
*/ |
|
44 |
public static <T> RestResult<T> err(String code, T data) { |
|
45 |
return genResult(code, data); |
|
46 |
} |
|
47 |
|
|
48 |
} |