Skip to content

Commit

Permalink
🆕 #2831 【开放平台】新增小程序DNS预解析域名相关接口
Browse files Browse the repository at this point in the history
  • Loading branch information
xgao-z authored and binarywang committed Oct 3, 2022
1 parent 3bd517a commit d759317
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaAuditMediaUploadResult;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.open.bean.ma.WxMaPrefetchDomain;
import me.chanjar.weixin.open.bean.ma.WxMaScheme;
import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage;
import me.chanjar.weixin.open.bean.result.*;
Expand Down Expand Up @@ -256,6 +257,16 @@ public interface WxOpenMaService extends WxMaService {
*/
String API_GET_VERSION_INFO = "https://api.weixin.qq.com/wxa/getversioninfo";

/**
* 设置DNS预解析域名
*/
String API_WX_SET_PREFETCH_DOMAIN = "https://api.weixin.qq.com/wxa/set_prefetchdnsdomain";

/**
* 获取DNS预解析域名
*/
String API_GET_PREFETCH_DOMAIN = "https://api.weixin.qq.com/wxa/get_prefetchdnsdomain";

/**
* 获得小程序的域名配置信息
*
Expand Down Expand Up @@ -715,4 +726,21 @@ WxOpenMaDomainResult modifyDomain(String action, List<String> requestDomains, Li
*/
WxOpenVersioninfoResult getVersionInfo() throws WxErrorException;

/**
* 设置DNS预解析域名
*
* @param domain 预解析域名列表
* @return {@link WxOpenResult}
* @throws WxErrorException the wx error exception
*/
WxOpenResult setPrefetchDomain(WxMaPrefetchDomain domain) throws WxErrorException;

/**
* 获取DNS预解析域名
*
* @return {@link WxOpenMaPrefetchDomainResult}
* @throws WxErrorException he wx error exception
*/
WxOpenMaPrefetchDomainResult getPrefetchDomain() throws WxErrorException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import me.chanjar.weixin.open.api.WxOpenMaBasicService;
import me.chanjar.weixin.open.api.WxOpenMaPrivacyService;
import me.chanjar.weixin.open.api.WxOpenMaService;
import me.chanjar.weixin.open.bean.ma.WxMaPrefetchDomain;
import me.chanjar.weixin.open.bean.ma.WxMaQrcodeParam;
import me.chanjar.weixin.open.bean.ma.WxMaScheme;
import me.chanjar.weixin.open.bean.message.WxOpenMaSubmitAuditMessage;
Expand Down Expand Up @@ -446,4 +447,16 @@ public WxOpenVersioninfoResult getVersionInfo() throws WxErrorException {
String response = post(API_GET_VERSION_INFO, GSON.toJson(params));
return WxMaGsonBuilder.create().fromJson(response, WxOpenVersioninfoResult.class);
}

@Override
public WxOpenResult setPrefetchDomain(WxMaPrefetchDomain domain) throws WxErrorException {
String response = post(API_WX_SET_PREFETCH_DOMAIN, GSON.toJson(domain));
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}

@Override
public WxOpenMaPrefetchDomainResult getPrefetchDomain() throws WxErrorException {
String response = get(API_GET_PREFETCH_DOMAIN, null);
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaPrefetchDomainResult.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package me.chanjar.weixin.open.bean.ma;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
* @author 清心
* create on 2022-10-01 18:07
*/
@Data
public class WxMaPrefetchDomain implements Serializable {
private static final long serialVersionUID = 1593947263587362155L;

@SerializedName("prefetch_dns_domain")
private List<DnsDomain> prefetchDnsDomain;

@Data
public static class DnsDomain {
private String url;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package me.chanjar.weixin.open.bean.result;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
* @author 清心
* create on 2022-10-01 18:25
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class WxOpenMaPrefetchDomainResult extends WxOpenResult{

@SerializedName("prefetch_dns_domain")
private List<PreDnsDomain> prefetchDnsDomain;

@SerializedName("size_limit")
private Integer sizeLimit;

@Data
public static class PreDnsDomain {

@SerializedName("url")
private String url;

@SerializedName("status")
private Integer status;
}

}

0 comments on commit d759317

Please sign in to comment.