#1172 实现微信开放平台第三方小程序分阶段发布功能以及其他相关接口

This commit is contained in:
S 2019-08-23 09:34:35 +08:00 committed by Binary Wang
parent 3e948ec01b
commit 8f1c7420a5
4 changed files with 272 additions and 2 deletions

View File

@ -187,6 +187,13 @@ public interface WxOpenMaService extends WxMaService {
*/
String getWebViewDomain() throws WxErrorException;
/**
* 获取小程序的业务域名
*
* @return
*/
public WxOpenResult getWebViewDomainInfo() throws WxErrorException;
/**
* 设置小程序的业务域名
*
@ -195,6 +202,16 @@ public interface WxOpenMaService extends WxMaService {
*/
String setWebViewDomain(String action, List<String> domainList) throws WxErrorException;
/**
* 设置小程序的业务域名
*
* @param action add添加, delete删除, set覆盖
* @param domainList
* @return
*/
WxOpenResult setWebViewDomainInfo(String action, List<String> domainList) throws WxErrorException;
/**
* 获取小程序的信息
*/
@ -272,6 +289,12 @@ public interface WxOpenMaService extends WxMaService {
*/
WxOpenResult releaesAudited() throws WxErrorException;
/**
* 10. 修改小程序线上代码的可见状态仅供第三方代小程序调用
*/
public WxOpenResult changeVisitstatus(String action) throws WxErrorException;
/**
* 11. 小程序版本回退仅供第三方代小程序调用
*/
@ -288,9 +311,34 @@ public interface WxOpenMaService extends WxMaService {
*/
String getSupportVersion() throws WxErrorException;
/**
* 查询当前设置的最低基础库版本及各版本用户占比 仅供第三方代小程序调用
*/
WxOpenMaWeappSupportVersionResult getSupportVersionInfo() throws WxErrorException;
/**
* 设置最低基础库版本仅供第三方代小程序调用
*/
String setSupportVersion(String version) throws WxErrorException;
/**
* 设置最低基础库版本仅供第三方代小程序调用
*/
WxOpenResult setSupportVersionInfo(String version) throws WxErrorException;
/**
* 16. 小程序分阶段发布 - 1)分阶段发布接口
*/
WxOpenResult grayrelease(Integer grayPercentage) throws WxErrorException;
/**
* 16. 小程序分阶段发布 - 2)取消分阶段发布
*/
WxOpenResult revertgrayrelease() throws WxErrorException;
/**
* 16. 小程序分阶段发布 - 3)查询当前分阶段发布详情
*/
WxOpenMaGrayReleasePlanResult getgrayreleaseplan() throws WxErrorException;
}

View File

@ -104,6 +104,16 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
return setWebViewDomain("get", null);
}
/**
* 获取小程序的业务域名
*
* @return
*/
@Override
public WxOpenResult getWebViewDomainInfo() throws WxErrorException {
return setWebViewDomainInfo("get", null);
}
/**
* 设置小程序的业务域名
*
@ -123,6 +133,20 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
return response;
}
/**
* 设置小程序的业务域名
*
* @param action add添加, delete删除, set覆盖
* @return
*/
@Override
public WxOpenResult setWebViewDomainInfo(String action, List<String> domainList) throws WxErrorException {
String response = this.setWebViewDomain(action, domainList);
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
/**
* 获取小程序的信息,GET请求
* <pre>
@ -139,6 +163,7 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
return response;
}
/**
* 绑定小程序体验者
*
@ -302,6 +327,22 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
/**
* 10. 修改小程序线上代码的可见状态仅供第三方代小程序调用
* @param action 设置可访问状态发布后默认可访问close为不可见open为可见
* @return
* @throws WxErrorException
*/
@Override
public WxOpenResult changeVisitstatus(String action) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("action", action);
String response = post(API_CHANGE_VISITSTATUS, GSON.toJson(params));
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
/**
* 11. 小程序版本回退仅供第三方代小程序调用
*
@ -314,6 +355,7 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
/**
* 15. 小程序审核撤回
* <p>
@ -330,7 +372,7 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
}
/**
* 查询当前设置的最低基础库版本及各版本用户占比 仅供第三方代小程序调用
* 12. 查询当前设置的最低基础库版本及各版本用户占比 仅供第三方代小程序调用
*
* @return
* @throws WxErrorException
@ -342,8 +384,21 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
return response;
}
/**
* 设置最低基础库版本仅供第三方代小程序调用
* 12. 查询当前设置的最低基础库版本及各版本用户占比 仅供第三方代小程序调用
*
* @return
* @throws WxErrorException
*/
@Override
public WxOpenMaWeappSupportVersionResult getSupportVersionInfo() throws WxErrorException {
String response = this.getSupportVersion();
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaWeappSupportVersionResult.class);
}
/**
* 13. 设置最低基础库版本仅供第三方代小程序调用
*
* @param version
* @return
@ -357,6 +412,66 @@ public class WxOpenMaServiceImpl extends WxMaServiceImpl implements WxOpenMaServ
return response;
}
/**
* 13. 设置最低基础库版本仅供第三方代小程序调用
*
* @param version
* @return
* @throws WxErrorException
*/
@Override
public WxOpenResult setSupportVersionInfo(String version) throws WxErrorException {
String response = this.setSupportVersion(version);
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
/**
* 16. 小程序分阶段发布 - 1)分阶段发布接口
*
* @param grayPercentage 灰度的百分比1到100的整数
* @return
* @throws WxErrorException
*/
@Override
public WxOpenResult grayrelease(Integer grayPercentage) throws WxErrorException {
JsonObject params = new JsonObject();
params.addProperty("gray_percentage", grayPercentage);
String response = post(API_GRAY_RELEASE, GSON.toJson(params));
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
/**
* 16. 小程序分阶段发布 - 2)取消分阶段发布
*
* @return
* @throws WxErrorException
*/
@Override
public WxOpenResult revertgrayrelease() throws WxErrorException {
String response = get(API_REVERT_GRAY_RELEASE, null);
return WxMaGsonBuilder.create().fromJson(response, WxOpenResult.class);
}
/**
* 16. 小程序分阶段发布 - 3)查询当前分阶段发布详情
*
* @return
* @throws WxErrorException
*/
@Override
public WxOpenMaGrayReleasePlanResult getgrayreleaseplan() throws WxErrorException {
String response = get(API_GET_GRAY_RELEASE_PLAN, null);
return WxMaGsonBuilder.create().fromJson(response, WxOpenMaGrayReleasePlanResult.class);
}
/**
* 将字符串对象转化为GsonArray对象
*

View File

@ -0,0 +1,54 @@
package me.chanjar.weixin.open.bean.result;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* 微信开放平台小程序当前分阶段发布详情
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxOpenMaGrayReleasePlanResult extends WxOpenResult {
private static final long serialVersionUID = 8417849861393170728L;
@SerializedName("gray_release_plan")
private GrayReleasePlanBean grayReleasePlan;
@Data
public static class GrayReleasePlanBean {
/**
* 0:初始状态 1:执行中 2:暂停中 3:执行完毕 4:被删除
*/
@SerializedName("status")
private Integer status;
/**
* 创建时间
*/
@SerializedName("create_timestamp")
private Long createTimestamp;
/**
* 灰度百分比
*/
@SerializedName("gray_percentage")
private Integer grayPercentage;
}
@Override
public String toString() {
return WxOpenGsonBuilder.create().toJson(this);
}
}

View File

@ -0,0 +1,53 @@
package me.chanjar.weixin.open.bean.result;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.open.util.json.WxOpenGsonBuilder;
import java.util.List;
/**
* 查询当前设置的最低基础库版本及各版本用户占比
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxOpenMaWeappSupportVersionResult extends WxOpenResult {
private static final long serialVersionUID = -2955725249930665377L;
@SerializedName("now_version")
String nowVersion;
@SerializedName("uv_info")
UvInfoBean uvInfo;
@Data
public static class UvInfoBean {
@SerializedName("items")
List<VersionPercentageBean> items;
}
@Data
public static class VersionPercentageBean {
@SerializedName("percentage")
private Integer percentage;
@SerializedName("version")
private String version;
}
@Override
public String toString() {
return WxOpenGsonBuilder.create().toJson(this);
}
}