|
36 | 36 | * created on 2018-09-12 |
37 | 37 | */ |
38 | 38 | public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaService { |
| 39 | + private static final String ACTION = "action"; |
| 40 | + private static final String ACTION_GET = "get"; |
39 | 41 | private final WxOpenComponentService wxOpenComponentService; |
40 | 42 | private final WxMaConfig wxMaConfig; |
41 | 43 | private final String appId; |
@@ -73,41 +75,44 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException { |
73 | 75 |
|
74 | 76 | @Override |
75 | 77 | public WxOpenMaDomainResult getDomain() throws WxErrorException { |
76 | | - return modifyDomain("get", null, null, null, null); |
| 78 | + return modifyDomain(ACTION_GET, null, null, null, |
| 79 | + null, null, null); |
77 | 80 | } |
78 | 81 |
|
79 | 82 | @Override |
80 | | - public WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, List<String> wsRequestDomains, List<String> uploadDomains, List<String> downloadDomains) throws WxErrorException { |
81 | | -// if (!"get".equals(action) && (requestdomainList == null || wsrequestdomainList == null || uploaddomainList == null || downloaddomainList == null)) { |
82 | | -// throw new WxErrorException(WxError.builder().errorCode(44004).errorMsg("域名参数不能为空").build()); |
83 | | -// } |
| 83 | + public WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, List<String> wsRequestDomains, |
| 84 | + List<String> uploadDomains, List<String> downloadDomains, |
| 85 | + List<String> udpDomains, List<String> tcpDomains) throws WxErrorException { |
84 | 86 | JsonObject requestJson = new JsonObject(); |
85 | | - requestJson.addProperty("action", action); |
86 | | - if (!"get".equals(action)) { |
| 87 | + requestJson.addProperty(ACTION, action); |
| 88 | + if (!ACTION_GET.equals(action)) { |
87 | 89 | requestJson.add("requestdomain", toJsonArray(requestDomains)); |
88 | 90 | requestJson.add("wsrequestdomain", toJsonArray(wsRequestDomains)); |
89 | 91 | requestJson.add("uploaddomain", toJsonArray(uploadDomains)); |
90 | 92 | requestJson.add("downloaddomain", toJsonArray(downloadDomains)); |
| 93 | + requestJson.add("udpdomain", toJsonArray(udpDomains)); |
| 94 | + requestJson.add("tcpdomain", toJsonArray(tcpDomains)); |
91 | 95 | } |
| 96 | + |
92 | 97 | String response = post(API_MODIFY_DOMAIN, GSON.toJson(requestJson)); |
93 | 98 | return WxMaGsonBuilder.create().fromJson(response, WxOpenMaDomainResult.class); |
94 | 99 | } |
95 | 100 |
|
96 | 101 | @Override |
97 | 102 | public String getWebViewDomain() throws WxErrorException { |
98 | | - return setWebViewDomain("get", null); |
| 103 | + return setWebViewDomain(ACTION_GET, null); |
99 | 104 | } |
100 | 105 |
|
101 | 106 | @Override |
102 | 107 | public WxOpenMaWebDomainResult getWebViewDomainInfo() throws WxErrorException { |
103 | | - return setWebViewDomainInfo("get", null); |
| 108 | + return setWebViewDomainInfo(ACTION_GET, null); |
104 | 109 | } |
105 | 110 |
|
106 | 111 | @Override |
107 | 112 | public String setWebViewDomain(String action, List<String> domainList) throws WxErrorException { |
108 | 113 | JsonObject requestJson = new JsonObject(); |
109 | | - requestJson.addProperty("action", action); |
110 | | - if (!"get".equals(action)) { |
| 114 | + requestJson.addProperty(ACTION, action); |
| 115 | + if (!ACTION_GET.equals(action)) { |
111 | 116 | requestJson.add("webviewdomain", toJsonArray(domainList)); |
112 | 117 | } |
113 | 118 | return post(API_SET_WEBVIEW_DOMAIN, GSON.toJson(requestJson)); |
@@ -159,7 +164,7 @@ public WxOpenResult unbindTesterByUserStr(String userStr) throws WxErrorExceptio |
159 | 164 | @Override |
160 | 165 | public WxOpenMaTesterListResult getTesterList() throws WxErrorException { |
161 | 166 | JsonObject paramJson = new JsonObject(); |
162 | | - paramJson.addProperty("action", "get_experiencer"); |
| 167 | + paramJson.addProperty(ACTION, "get_experiencer"); |
163 | 168 | String response = post(API_GET_TESTERLIST, GSON.toJson(paramJson)); |
164 | 169 | return WxMaGsonBuilder.create().fromJson(response, WxOpenMaTesterListResult.class); |
165 | 170 | } |
@@ -255,7 +260,7 @@ public WxOpenResult releaseAudited() throws WxErrorException { |
255 | 260 | @Override |
256 | 261 | public WxOpenResult changeVisitStatus(String action) throws WxErrorException { |
257 | 262 | JsonObject params = new JsonObject(); |
258 | | - params.addProperty("action", action); |
| 263 | + params.addProperty(ACTION, action); |
259 | 264 | String response = post(API_CHANGE_VISITSTATUS, GSON.toJson(params)); |
260 | 265 | return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class); |
261 | 266 | } |
@@ -450,7 +455,7 @@ public WxOpenMaPrefetchDomainResult getPrefetchDomain() throws WxErrorException |
450 | 455 | @Override |
451 | 456 | public WxOpenMaApplyLiveInfoResult applyLiveInfo() throws WxErrorException { |
452 | 457 | JsonObject params = new JsonObject(); |
453 | | - params.addProperty("action", "apply"); |
| 458 | + params.addProperty(ACTION, "apply"); |
454 | 459 | String response = post(API_WX_APPLY_LIVE_INFO, GSON.toJson(params)); |
455 | 460 | return WxMaGsonBuilder.create().fromJson(response, WxOpenMaApplyLiveInfoResult.class); |
456 | 461 | } |
|
0 commit comments