Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序代码管理增加 查询小程序版本信息 接口功能 #2588

Merged
merged 4 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -105,6 +105,14 @@ public interface WxMaCodeService {
*/
WxMaCodeVersionDistribution getSupportVersion() throws WxErrorException;

/**
* 查询小程序版本信息
*
* @return 小程序的体验版和线上版本信息
* @throws WxErrorException 失败时抛出,具体错误码请看此接口的注释文档
*/
WxMaCodeVersionInfo getVersionInfo() throws WxErrorException;

/**
* 设置最低基础库版本(仅供第三方代小程序调用).
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ public WxMaCodeVersionDistribution getSupportVersion() throws WxErrorException {
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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 {

leonxi marked this conversation as resolved.
Show resolved Hide resolved
/**
* 体验版信息
*/
@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
static class ExpInfo implements Serializable {
leonxi marked this conversation as resolved.
Show resolved Hide resolved

/**
* 提交体验版的时间
*/
@SerializedName("exp_time")
private Long expTime;

/**
* 体验版版本信息
*/
@SerializedName("exp_version")
private String expVersion;

/**
* 体验版版本描述
*/
@SerializedName("exp_desc")
private String expDesc;
}

@Data
@NoArgsConstructor
@AllArgsConstructor
static class ReleaseInfo implements Serializable {

/**
* 发布线上版的时间
*/
@SerializedName("release_time")
private Long releaseTime;

/**
* 线上版版本信息
*/
@SerializedName("release_version")
private String releaseVersion;

/**
* 线上版本描述
*/
@SerializedName("release_desc")
private String releaseDesc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public interface Code {
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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package cn.binarywang.wx.miniapp.api.impl;

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.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 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>
Expand Down Expand Up @@ -143,6 +139,12 @@ public void testGetSupportVersion() throws Exception {
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");
Expand Down