Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,21 @@ public interface WxOpenComponentService {

String COMPONENT_CLEAR_QUOTA_URL = "https://api.weixin.qq.com/cgi-bin/component/clear_quota/v2";

/**
* 设置第三方平台服务器域名
*/
String API_MODIFY_WXA_SERVER_DOMAIN = "https://api.weixin.qq.com/cgi-bin/component/modify_wxa_server_domain";

/**
* 获取第三方平台业务域名校验文件
*/
String API_GET_DOMAIN_CONFIRM_FILE = "https://api.weixin.qq.com/cgi-bin/component/get_domain_confirmfile";

/**
* 设置第三方平台业务域名
*/
String API_MODIFY_WXA_JUMP_DOMAIN = "https://api.weixin.qq.com/cgi-bin/component/modify_wxa_jump_domain";

/**
* Gets wx mp service by appid.
*
Expand Down Expand Up @@ -1117,4 +1132,53 @@ public interface WxOpenComponentService {
*/
WxOpenResult applySetOrderPathInfo(WxOpenMaApplyOrderPathInfo info) throws WxErrorException;

/**
* 设置第三方平台服务器域名
* <a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/domain/modify_server_domain.html">文档地址</a>
*
* @param action add添加, delete删除, set覆盖, get获取
* @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 modifyWxaServerDomain(String action, List<String> requestDomains, List<String> wsRequestDomains,
List<String> uploadDomains, List<String> downloadDomains,
List<String> udpDomains, List<String> tcpDomains) throws WxErrorException;

/**
* 获取第三方平台业务域名校验文件
* <a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/domain/get_domain_confirmfile.html">文档地址</a>
*
* @return 业务域名校验文件信息
* @throws WxErrorException 操作失败时抛出,具体错误码请看文档
*/
WxOpenMaDomainConfirmFileResult getDomainConfirmFile() throws WxErrorException;

/**
* 设置第三方平台业务域名
* <a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/domain/modify_jump_domain.html">文档地址</a>
*
* @param action add添加, delete删除, set覆盖, get获取
* @param domainList the domain list
* @return 直接返回字符串
* @throws WxErrorException the wx error exception
*/
String modifyWxaJumpDomain(String action, List<String> domainList) throws WxErrorException;

/**
* 设置第三方平台业务域名
* <a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/ThirdParty/domain/modify_jump_domain.html">文档地址</a>
*
* @param action add添加, delete删除, set覆盖, get获取
* @param domainList the domain list
* @return web view domain info
* @throws WxErrorException the wx error exception
*/
WxOpenMaWebDomainResult modifyWxaJumpDomainInfo(String action, List<String> domainList) throws WxErrorException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public interface WxOpenMaService extends WxMaService {
*/
String API_MODIFY_DOMAIN = "https://api.weixin.qq.com/wxa/modify_domain";

/**
* 快速配置小程序服务器域名
*/
String API_MODIFY_DOMAIN_DIRECTLY = "https://api.weixin.qq.com/wxa/modify_domain_directly";

/**
* 设置小程序业务域名(仅供第三方代小程序调用)
* <pre>
Expand All @@ -44,6 +49,11 @@ public interface WxOpenMaService extends WxMaService {
*/
String API_SET_WEBVIEW_DOMAIN = "https://api.weixin.qq.com/wxa/setwebviewdomain";

/**
* 快速配置小程序业务域名
*/
String API_SET_WEBVIEW_DOMAIN_DIRECTLY = "https://api.weixin.qq.com/wxa/setwebviewdomain_directly";

/**
* 获取业务域名校验文件(仅供第三方代小程序调用)
*/
Expand Down Expand Up @@ -310,6 +320,24 @@ WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, Li
List<String> uploadDomains, List<String> downloadDomains,
List<String> udpDomains, List<String> tcpDomains) throws WxErrorException;

/**
* 快速配置小程序服务器域名
* <a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/modify_domain_directly.html">文档地址</a>
*
* @param action add添加, delete删除, set覆盖, get获取
* @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 modifyDomainDirectly(String action, List<String> requestDomains, List<String> wsRequestDomains,
List<String> uploadDomains, List<String> downloadDomains,
List<String> udpDomains, List<String> tcpDomains) throws WxErrorException;

/**
* 获取小程序的业务域名
*
Expand Down Expand Up @@ -346,6 +374,28 @@ WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, Li
*/
WxOpenMaWebDomainResult setWebViewDomainInfo(String action, List<String> domainList) throws WxErrorException;

/**
* 快速配置小程序业务域名
* <a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/setwebviewdomain_directly.html">文档地址</a>
*
* @param action add添加, delete删除, set覆盖, get获取
* @param domainList the domain list
* @return 直接返回字符串
* @throws WxErrorException the wx error exception
*/
String setWebViewDomainDirectly(String action, List<String> domainList) throws WxErrorException;

/**
* 快速配置小程序业务域名
* <a href="https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/setwebviewdomain_directly.html">文档地址</a>
*
* @param action add添加, delete删除, set覆盖, get获取
* @param domainList the domain list
* @return web view domain info
* @throws WxErrorException the wx error exception
*/
WxOpenMaWebDomainResult setWebViewDomainDirectlyInfo(String action, List<String> domainList) throws WxErrorException;

/**
* 获取业务域名校验文件
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,4 +1307,55 @@ public WxOpenResult applySetOrderPathInfo(WxOpenMaApplyOrderPathInfo info) throw
String response = post(OPEN_APPLY_SET_ORDER_PATH_INFO, gson.toJson(info));
return WxOpenGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

@Override
public WxOpenMaDomainResult modifyWxaServerDomain(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.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_WXA_SERVER_DOMAIN, requestJson.toString());
return WxOpenGsonBuilder.create().fromJson(response, WxOpenMaDomainResult.class);
}

@Override
public WxOpenMaDomainConfirmFileResult getDomainConfirmFile() throws WxErrorException {
String responseContent = post(API_GET_DOMAIN_CONFIRM_FILE, "{}");
return WxOpenMaDomainConfirmFileResult.fromJson(responseContent);
}

@Override
public String modifyWxaJumpDomain(String action, List<String> domainList) throws WxErrorException {
JsonObject requestJson = new JsonObject();
requestJson.addProperty("action", action);
if (!"get".equals(action)) {
requestJson.add("webviewdomain", toJsonArray(domainList));
}
return post(API_MODIFY_WXA_JUMP_DOMAIN, requestJson.toString());
}

@Override
public WxOpenMaWebDomainResult modifyWxaJumpDomainInfo(String action, List<String> domainList) throws WxErrorException {
String response = this.modifyWxaJumpDomain(action, domainList);
return WxOpenGsonBuilder.create().fromJson(response, WxOpenMaWebDomainResult.class);
}

private JsonArray toJsonArray(List<String> list) {
JsonArray jsonArray = new JsonArray();
if (list != null) {
for (String item : list) {
jsonArray.add(item);
}
}
return jsonArray;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ public WxOpenMaDomainResult modifyDomain(String action, List<String> requestDoma
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaDomainResult.class);
}

@Override
public WxOpenMaDomainResult modifyDomainDirectly(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 (!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_DIRECTLY, GSON.toJson(requestJson));
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaDomainResult.class);
}

@Override
public String getWebViewDomain() throws WxErrorException {
return setWebViewDomain(ACTION_GET, null);
Expand Down Expand Up @@ -140,6 +159,22 @@ public WxOpenMaWebDomainResult setWebViewDomainInfo(String action, List<String>
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaWebDomainResult.class);
}

@Override
public String setWebViewDomainDirectly(String action, List<String> domainList) throws WxErrorException {
JsonObject requestJson = new JsonObject();
requestJson.addProperty(ACTION, action);
if (!ACTION_GET.equals(action)) {
requestJson.add("webviewdomain", toJsonArray(domainList));
}
return post(API_SET_WEBVIEW_DOMAIN_DIRECTLY, GSON.toJson(requestJson));
}

@Override
public WxOpenMaWebDomainResult setWebViewDomainDirectlyInfo(String action, List<String> domainList) throws WxErrorException {
String response = this.setWebViewDomainDirectly(action, domainList);
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaWebDomainResult.class);
}

@Override
public WxOpenMaDomainConfirmFileResult getWebviewDomainConfirmFile() throws WxErrorException {
String responseContent = post(API_GET_WEBVIEW_DOMAIN_CONFIRM_FILE, "{}");
Expand Down