Gb1400ResponseUtil.java
3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package com.viontech.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.Date;
import java.util.List;
/**
* @author vion
**/
public class Gb1400ResponseUtil {
public static JSONObject success(String id, String requestURL) {
JSONObject response = new JSONObject();
response.put("Id", id);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", 0);
response.put("StatusString", "成功");
JSONObject result = new JSONObject();
result.put("ResponseStatusObject", response);
return result;
}
public static JSONObject success(String requestURL) {
JSONObject response = new JSONObject();
response.put("Id", null);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", 0);
response.put("StatusString", "成功");
JSONObject result = new JSONObject();
result.put("ResponseStatusObject", response);
return result;
}
public static JSONObject successList(String requestURL) {
JSONObject item = new JSONObject();
item.put("Id", null);
item.put("LocalTime", new Date());
item.put("RequestURL", requestURL);
item.put("StatusCode", 0);
item.put("StatusString", "成功");
JSONArray items = new JSONArray();
items.add(item);
JSONObject object = new JSONObject();
object.put("ResponseStatusObject", items);
JSONObject result = new JSONObject();
result.put("ResponseStatusListObject", object);
return result;
}
public static JSONObject responseStatusListObject(List<JSONObject> list) {
JSONObject object = new JSONObject();
object.put("ResponseStatusObject", list);
JSONObject result = new JSONObject();
result.put("ResponseStatusListObject", object);
return result;
}
public static JSONObject buildResponseStatusObject(String id, String requestURL, Integer StatusCode, String StatusString) {
JSONObject response = new JSONObject();
response.put("Id", id);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", StatusCode);
response.put("StatusString", StatusString);
return response;
}
public static JSONObject error(Integer errorNo, String errorMsg, String requestURL) {
JSONObject response = new JSONObject();
response.put("Id", null);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", errorNo);
response.put("StatusString", errorMsg);
JSONObject result = new JSONObject();
result.put("ResponseStatusObject", response);
return result;
}
public static JSONObject error(String id, Integer errorNo, String errorMsg, String requestURL) {
JSONObject response = new JSONObject();
response.put("Id", id);
response.put("LocalTime", new Date());
response.put("RequestURL", requestURL);
response.put("StatusCode", errorNo);
response.put("StatusString", errorMsg);
JSONObject result = new JSONObject();
result.put("ResponseStatusObject", response);
return result;
}
}