Skip to content

Commit 9db5841

Browse files
committed
🎨 #3182 【开放平台】 设置服务器域名接口方法增加tcp合法域名和 udp合法域名的参数
1 parent 20549a9 commit 9db5841

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenMaService.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,20 @@ public interface WxOpenMaService extends WxMaService {
277277

278278
/**
279279
* 修改域名
280-
*
280+
* <a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/Server_Address_Configuration.html">文档地址</a>
281281
* @param action delete删除, set覆盖, get获取
282-
* @param requestDomains the requestdomain list
283-
* @param wsRequestDomains the wsrequestdomain list
284-
* @param uploadDomains the uploaddomain list
285-
* @param downloadDomains the downloaddomain list
282+
* @param requestDomains request 合法域名;当 action 是 get 时不需要此字段
283+
* @param wsRequestDomains socket 合法域名;当 action 是 get 时不需要此字段
284+
* @param uploadDomains uploadFile 合法域名;当 action 是 get 时不需要此字段
285+
* @param downloadDomains downloadFile 合法域名;当 action 是 get 时不需要此字段
286+
* @param tcpDomains tcp 合法域名;当 action 是 get 时不需要此字段
287+
* @param udpDomains udp 合法域名;当 action 是 get 时不需要此字段
286288
* @return the wx open ma domain result
287289
* @throws WxErrorException the wx error exception
288290
*/
289291
WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, List<String> wsRequestDomains,
290-
List<String> uploadDomains, List<String> downloadDomains) throws WxErrorException;
292+
List<String> uploadDomains, List<String> downloadDomains,
293+
List<String> udpDomains, List<String> tcpDomains) throws WxErrorException;
291294

292295
/**
293296
* 获取小程序的业务域名

weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenMaServiceImpl.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
* created on 2018-09-12
3737
*/
3838
public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaService {
39+
private static final String ACTION = "action";
40+
private static final String ACTION_GET = "get";
3941
private final WxOpenComponentService wxOpenComponentService;
4042
private final WxMaConfig wxMaConfig;
4143
private final String appId;
@@ -73,41 +75,44 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {
7375

7476
@Override
7577
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);
7780
}
7881

7982
@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 {
8486
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)) {
8789
requestJson.add("requestdomain", toJsonArray(requestDomains));
8890
requestJson.add("wsrequestdomain", toJsonArray(wsRequestDomains));
8991
requestJson.add("uploaddomain", toJsonArray(uploadDomains));
9092
requestJson.add("downloaddomain", toJsonArray(downloadDomains));
93+
requestJson.add("udpdomain", toJsonArray(udpDomains));
94+
requestJson.add("tcpdomain", toJsonArray(tcpDomains));
9195
}
96+
9297
String response = post(API_MODIFY_DOMAIN, GSON.toJson(requestJson));
9398
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaDomainResult.class);
9499
}
95100

96101
@Override
97102
public String getWebViewDomain() throws WxErrorException {
98-
return setWebViewDomain("get", null);
103+
return setWebViewDomain(ACTION_GET, null);
99104
}
100105

101106
@Override
102107
public WxOpenMaWebDomainResult getWebViewDomainInfo() throws WxErrorException {
103-
return setWebViewDomainInfo("get", null);
108+
return setWebViewDomainInfo(ACTION_GET, null);
104109
}
105110

106111
@Override
107112
public String setWebViewDomain(String action, List<String> domainList) throws WxErrorException {
108113
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)) {
111116
requestJson.add("webviewdomain", toJsonArray(domainList));
112117
}
113118
return post(API_SET_WEBVIEW_DOMAIN, GSON.toJson(requestJson));
@@ -159,7 +164,7 @@ public WxOpenResult unbindTesterByUserStr(String userStr) throws WxErrorExceptio
159164
@Override
160165
public WxOpenMaTesterListResult getTesterList() throws WxErrorException {
161166
JsonObject paramJson = new JsonObject();
162-
paramJson.addProperty("action", "get_experiencer");
167+
paramJson.addProperty(ACTION, "get_experiencer");
163168
String response = post(API_GET_TESTERLIST, GSON.toJson(paramJson));
164169
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaTesterListResult.class);
165170
}
@@ -255,7 +260,7 @@ public WxOpenResult releaseAudited() throws WxErrorException {
255260
@Override
256261
public WxOpenResult changeVisitStatus(String action) throws WxErrorException {
257262
JsonObject params = new JsonObject();
258-
params.addProperty("action", action);
263+
params.addProperty(ACTION, action);
259264
String response = post(API_CHANGE_VISITSTATUS, GSON.toJson(params));
260265
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
261266
}
@@ -450,7 +455,7 @@ public WxOpenMaPrefetchDomainResult getPrefetchDomain() throws WxErrorException
450455
@Override
451456
public WxOpenMaApplyLiveInfoResult applyLiveInfo() throws WxErrorException {
452457
JsonObject params = new JsonObject();
453-
params.addProperty("action", "apply");
458+
params.addProperty(ACTION, "apply");
454459
String response = post(API_WX_APPLY_LIVE_INFO, GSON.toJson(params));
455460
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaApplyLiveInfoResult.class);
456461
}

0 commit comments

Comments
 (0)