提交 | 用户 | age
|
5c5945
|
1 |
package com.hx.resultTool; |
E |
2 |
|
|
3 |
import java.io.Serializable; |
|
4 |
|
|
5 |
/** |
|
6 |
* 统一返回格式 |
|
7 |
* @author chenjiahe |
|
8 |
* @Data: 2020-06-20 |
|
9 |
*/ |
|
10 |
public class Result implements Serializable { |
|
11 |
|
|
12 |
private static final long serialVersionUID = -3948389268046368059L; |
|
13 |
|
|
14 |
private String code; |
|
15 |
|
|
16 |
private String msg; |
|
17 |
|
|
18 |
private Object data; |
|
19 |
|
|
20 |
public Result() {} |
|
21 |
|
|
22 |
public Result(String code, String msg) { |
|
23 |
this.code = code; |
|
24 |
this.msg = msg; |
|
25 |
} |
|
26 |
|
|
27 |
public static Result success() { |
|
28 |
Result Result = new Result(); |
|
29 |
Result.setCode(ResponseCode.SUCCESS); |
|
30 |
Result.setMsg("SUCCESS"); |
|
31 |
return Result; |
|
32 |
} |
|
33 |
|
|
34 |
public static Result success(Object data) { |
|
35 |
Result Result = new Result(); |
|
36 |
Result.setCode(ResponseCode.SUCCESS); |
|
37 |
Result.setData(data); |
|
38 |
Result.setMsg("SUCCESS"); |
|
39 |
return Result; |
|
40 |
} |
|
41 |
|
|
42 |
public static Result failure(String code, String msg) { |
|
43 |
Result Result = new Result(); |
|
44 |
Result.setCode(code); |
|
45 |
Result.setMsg(msg); |
|
46 |
return Result; |
|
47 |
} |
|
48 |
|
|
49 |
public static Result failure(String code, String msg, Object data) { |
|
50 |
Result Result = new Result(); |
|
51 |
Result.setCode(code); |
|
52 |
Result.setMsg(msg); |
|
53 |
Result.setData(data); |
|
54 |
return Result; |
|
55 |
} |
|
56 |
|
|
57 |
/*******************************************************************************/ |
|
58 |
|
|
59 |
public String getCode() { |
|
60 |
return this.code; |
|
61 |
} |
|
62 |
|
|
63 |
public void setCode(final String code) { |
|
64 |
this.code = code; |
|
65 |
} |
|
66 |
|
|
67 |
public String getMsg() { |
|
68 |
return this.msg; |
|
69 |
} |
|
70 |
|
|
71 |
public void setMsg(final String msg) { |
|
72 |
this.msg = msg; |
|
73 |
} |
|
74 |
|
|
75 |
public Object getData() { |
|
76 |
return this.data; |
|
77 |
} |
|
78 |
|
|
79 |
public void setData(final Object data) { |
|
80 |
this.data = data; |
|
81 |
} |
|
82 |
|
|
83 |
} |
|
84 |
|