🆕 #2588 【小程序】代码管理增加查询小程序版本信息的接口

This commit is contained in:
Leon 2022-04-14 14:32:58 +08:00 committed by GitHub
parent a88619a7dc
commit f3921c7332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 123 additions and 15 deletions

View File

@ -105,6 +105,14 @@ public interface WxMaCodeService {
*/
WxMaCodeVersionDistribution getSupportVersion() throws WxErrorException;
/**
* 查询小程序版本信息
*
* @return 小程序的体验版和线上版本信息
* @throws WxErrorException 失败时抛出具体错误码请看此接口的注释文档
*/
WxMaCodeVersionInfo getVersionInfo() throws WxErrorException;
/**
* 设置最低基础库版本仅供第三方代小程序调用.
*

View File

@ -138,6 +138,12 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
return WxMaCodeVersionDistribution.fromJson(responseContent);
}
@Override
public WxMaCodeVersionInfo getVersionInfo() throws WxErrorException {
String responseContent = this.service.post(GET_VERSION_INFO_URL, "{}");
return WxMaCodeVersionInfo.fromJson(responseContent);
}
@Override
public void setSupportVersion(String version) throws WxErrorException {
JsonObject param = new JsonObject();

View File

@ -0,0 +1,91 @@
package cn.binarywang.wx.miniapp.bean.code;
import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 查询小程序版本信息
*
* @author <a href="https://github.com/leonxi">LeonXi</a>
* @since 2022-04-13 16:45
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WxMaCodeVersionInfo implements Serializable {
private static final long serialVersionUID = 6929700728659511688L;
/**
* 体验版信息
*/
@SerializedName("exp_info")
private ExpInfo expInfo;
/**
* 线上版信息
*/
@SerializedName("release_info")
private ReleaseInfo releaseInfo;
public static WxMaCodeVersionInfo fromJson(String json) {
return WxMaGsonBuilder.create().fromJson(json, WxMaCodeVersionInfo.class);
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class ExpInfo implements Serializable {
private static final long serialVersionUID = 6315578419554592943L;
/**
* 提交体验版的时间
*/
@SerializedName("exp_time")
private Long expTime;
/**
* 体验版版本信息
*/
@SerializedName("exp_version")
private String expVersion;
/**
* 体验版版本描述
*/
@SerializedName("exp_desc")
private String expDesc;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class ReleaseInfo implements Serializable {
private static final long serialVersionUID = 2098307354673939939L;
/**
* 发布线上版的时间
*/
@SerializedName("release_time")
private Long releaseTime;
/**
* 线上版版本信息
*/
@SerializedName("release_version")
private String releaseVersion;
/**
* 线上版本描述
*/
@SerializedName("release_desc")
private String releaseDesc;
}
}

View File

@ -70,6 +70,7 @@ public class WxMaApiUrlConstants {
String GET_SUPPORT_VERSION_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/getweappsupportversion";
String SET_SUPPORT_VERSION_URL = "https://api.weixin.qq.com/cgi-bin/wxopen/setweappsupportversion";
String UNDO_CODE_AUDIT_URL = "https://api.weixin.qq.com/wxa/undocodeaudit";
String GET_VERSION_INFO_URL = "https://api.weixin.qq.com/wxa/getversioninfo";
}
public interface Express {

View File

@ -1,25 +1,21 @@
package cn.binarywang.wx.miniapp.api.impl;
import cn.binarywang.wx.miniapp.api.WxMaCodeService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.code.*;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.test.ApiTestModule;
import com.google.inject.Inject;
import org.testng.annotations.Guice;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.testng.annotations.*;
import cn.binarywang.wx.miniapp.api.WxMaCodeService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.code.WxMaCategory;
import cn.binarywang.wx.miniapp.bean.code.WxMaCodeAuditStatus;
import cn.binarywang.wx.miniapp.bean.code.WxMaCodeCommitRequest;
import cn.binarywang.wx.miniapp.bean.code.WxMaCodeExtConfig;
import cn.binarywang.wx.miniapp.bean.code.WxMaCodeSubmitAuditRequest;
import cn.binarywang.wx.miniapp.bean.code.WxMaCodeVersionDistribution;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.test.ApiTestModule;
import com.google.inject.Inject;
import static org.testng.Assert.*;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
* @author <a href="https://github.com/charmingoh">Charming</a>
@ -143,6 +139,12 @@ public class WxMaCodeServiceImplTest {
System.out.println(distribution);
}
@Test
public void testGetVersionInfo() throws Exception {
WxMaCodeVersionInfo versionInfo = wxService.getCodeService().getVersionInfo();
System.out.println(versionInfo);
}
@Test
public void testSetSupportVersion() throws Exception {
wxService.getCodeService().setSupportVersion("1.2.0");