Skip to content

Commit

Permalink
🎨 #3182 【开放平台】 设置服务器域名接口方法增加tcp合法域名和 udp合法域名的参数
Browse files Browse the repository at this point in the history
  • Loading branch information
binarywang committed Dec 9, 2023
1 parent 20549a9 commit 9db5841
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,20 @@ public interface WxOpenMaService extends WxMaService {

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

/**
* 获取小程序的业务域名
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
* created on 2018-09-12
*/
public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaService {
private static final String ACTION = "action";
private static final String ACTION_GET = "get";
private final WxOpenComponentService wxOpenComponentService;
private final WxMaConfig wxMaConfig;
private final String appId;
Expand Down Expand Up @@ -73,41 +75,44 @@ public String getAccessToken(boolean forceRefresh) throws WxErrorException {

@Override
public WxOpenMaDomainResult getDomain() throws WxErrorException {
return modifyDomain("get", null, null, null, null);
return modifyDomain(ACTION_GET, null, null, null,
null, null, null);
}

@Override
public WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, List<String> wsRequestDomains, List<String> uploadDomains, List<String> downloadDomains) throws WxErrorException {
// if (!"get".equals(action) && (requestdomainList == null || wsrequestdomainList == null || uploaddomainList == null || downloaddomainList == null)) {
// throw new WxErrorException(WxError.builder().errorCode(44004).errorMsg("域名参数不能为空").build());
// }
public WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, List<String> wsRequestDomains,
List<String> uploadDomains, List<String> downloadDomains,
List<String> udpDomains, List<String> tcpDomains) throws WxErrorException {
JsonObject requestJson = new JsonObject();
requestJson.addProperty("action", action);
if (!"get".equals(action)) {
requestJson.addProperty(ACTION, action);
if (!ACTION_GET.equals(action)) {
requestJson.add("requestdomain", toJsonArray(requestDomains));
requestJson.add("wsrequestdomain", toJsonArray(wsRequestDomains));
requestJson.add("uploaddomain", toJsonArray(uploadDomains));
requestJson.add("downloaddomain", toJsonArray(downloadDomains));
requestJson.add("udpdomain", toJsonArray(udpDomains));
requestJson.add("tcpdomain", toJsonArray(tcpDomains));
}

String response = post(API_MODIFY_DOMAIN, GSON.toJson(requestJson));
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaDomainResult.class);
}

@Override
public String getWebViewDomain() throws WxErrorException {
return setWebViewDomain("get", null);
return setWebViewDomain(ACTION_GET, null);
}

@Override
public WxOpenMaWebDomainResult getWebViewDomainInfo() throws WxErrorException {
return setWebViewDomainInfo("get", null);
return setWebViewDomainInfo(ACTION_GET, null);
}

@Override
public String setWebViewDomain(String action, List<String> domainList) throws WxErrorException {
JsonObject requestJson = new JsonObject();
requestJson.addProperty("action", action);
if (!"get".equals(action)) {
requestJson.addProperty(ACTION, action);
if (!ACTION_GET.equals(action)) {
requestJson.add("webviewdomain", toJsonArray(domainList));
}
return post(API_SET_WEBVIEW_DOMAIN, GSON.toJson(requestJson));
Expand Down Expand Up @@ -159,7 +164,7 @@ public WxOpenResult unbindTesterByUserStr(String userStr) throws WxErrorExceptio
@Override
public WxOpenMaTesterListResult getTesterList() throws WxErrorException {
JsonObject paramJson = new JsonObject();
paramJson.addProperty("action", "get_experiencer");
paramJson.addProperty(ACTION, "get_experiencer");
String response = post(API_GET_TESTERLIST, GSON.toJson(paramJson));
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaTesterListResult.class);
}
Expand Down Expand Up @@ -255,7 +260,7 @@ public WxOpenResult releaseAudited() throws WxErrorException {
@Override
public WxOpenResult changeVisitStatus(String action) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("action", action);
params.addProperty(ACTION, action);
String response = post(API_CHANGE_VISITSTATUS, GSON.toJson(params));
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
Expand Down Expand Up @@ -450,7 +455,7 @@ public WxOpenMaPrefetchDomainResult getPrefetchDomain() throws WxErrorException
@Override
public WxOpenMaApplyLiveInfoResult applyLiveInfo() throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("action", "apply");
params.addProperty(ACTION, "apply");
String response = post(API_WX_APPLY_LIVE_INFO, GSON.toJson(params));
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaApplyLiveInfoResult.class);
}
Expand Down

0 comments on commit 9db5841

Please sign in to comment.