提交 | 用户 | age
|
826b66
|
1 |
package com.hz.util.http.dto; |
C |
2 |
|
|
3 |
import com.hx.exception.TipsException; |
|
4 |
|
|
5 |
/** |
|
6 |
* 请求返回统一dto |
|
7 |
*/ |
|
8 |
public class HttpHzResponse { |
|
9 |
|
|
10 |
/**请求状态*/ |
|
11 |
private String code; |
|
12 |
/**错误信息*/ |
|
13 |
private String msg; |
|
14 |
/**返回信息*/ |
|
15 |
private String data; |
|
16 |
|
|
17 |
/**请求返回状态-成功*/ |
|
18 |
public static final String CODE_200 = "200"; |
|
19 |
/**请求返回状态-成功*/ |
|
20 |
public static final String CODE_201 = "201"; |
|
21 |
/**请求状态-超时*/ |
|
22 |
public static final String CODE_TIME_OUT = "time_out"; |
|
23 |
|
|
24 |
/**封装校验请求码方法,没有进行错误提示*/ |
|
25 |
public boolean checkRequesCode(){ |
|
26 |
if(CODE_200.equals(code) || CODE_201.equals(code)){ |
|
27 |
return true; |
|
28 |
} |
|
29 |
return false; |
|
30 |
} |
|
31 |
|
|
32 |
/**封装校验请求码方法,进行错误提示*/ |
|
33 |
public void checkRequesThrow(){ |
|
34 |
if(!CODE_200.equals(code) && !CODE_201.equals(code)){ |
|
35 |
throw new TipsException("请求URL失败:"+this.msg); |
|
36 |
} |
|
37 |
|
|
38 |
} |
|
39 |
|
|
40 |
public String getCode() { |
|
41 |
return code; |
|
42 |
} |
|
43 |
|
|
44 |
public void setCode(String code) { |
|
45 |
this.code = code; |
|
46 |
} |
|
47 |
|
|
48 |
public String getMsg() { |
|
49 |
return msg; |
|
50 |
} |
|
51 |
|
|
52 |
public void setMsg(String msg) { |
|
53 |
this.msg = msg; |
|
54 |
} |
|
55 |
|
|
56 |
public String getData() { |
|
57 |
return data; |
|
58 |
} |
|
59 |
|
|
60 |
public void setData(String data) { |
|
61 |
this.data = data; |
|
62 |
} |
|
63 |
} |