#562 小程序增加代码管理相关 API
* 微信开放平台:1. WxOpenInRedisConfigStorage 支持 JedisPool/JedisSentinelPool 等 Pool<Jedis> 的子类;2. WxOpenInRedisConfigStorage 增加 keyPrefix 以支持可配置的前缀; * 微信开放平台:增加小程序代码模板库管理 * 小程序:增加代码管理相关 API
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
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.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 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.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/charmingoh">Charming</a>
|
||||
* @since 2018-04-26 20:18
|
||||
*/
|
||||
@Test
|
||||
@Guice(modules = ApiTestModule.class)
|
||||
public class WxMaCodeServiceImplTest {
|
||||
@Inject
|
||||
private WxMaService wxService;
|
||||
@Inject
|
||||
private WxMaConfig wxMaConfig;
|
||||
|
||||
@Test
|
||||
public void testGetCategory() throws Exception {
|
||||
List<WxMaCategory> categories = wxService.getCodeService().getCategory();
|
||||
System.out.println(String.valueOf(categories));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCommit() throws Exception {
|
||||
String themeColor = "#0074d9";
|
||||
String themeFontColor = "#ffffff";
|
||||
|
||||
Map<String, Object> ext = new HashMap<>();
|
||||
ext.put("appName", "xxx");
|
||||
ext.put("verified", true);
|
||||
ext.put("navigationBarBackgroundColor", themeColor);
|
||||
ext.put("navigationBarTextStyle", themeFontColor);
|
||||
ext.put("companyId", 4128);
|
||||
ext.put("companyFullName", "xxx有限公司");
|
||||
|
||||
WxMaCodeService wxMaCodeService = wxService.getCodeService();
|
||||
WxMaCodeCommitRequest commitRequest = WxMaCodeCommitRequest
|
||||
.builder()
|
||||
.templateId(6L)
|
||||
.userVersion("v0.1.0")
|
||||
.userDesc("init")
|
||||
.extConfig(WxMaCodeExtConfig.builder()
|
||||
.extAppid(wxMaConfig.getAppid())
|
||||
.extEnable(true)
|
||||
.ext(ext)
|
||||
.window(
|
||||
WxMaCodeExtConfig.PageConfig
|
||||
.builder()
|
||||
.navigationBarBackgroundColor(themeColor)
|
||||
.navigationBarTextStyle(themeFontColor)
|
||||
.build()
|
||||
)
|
||||
.build())
|
||||
.build();
|
||||
wxMaCodeService.commit(commitRequest);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetQrCode() throws Exception {
|
||||
byte[] qrCode = wxService.getCodeService().getQrCode();
|
||||
assertTrue(qrCode.length > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPage() throws Exception {
|
||||
List<String> pageList = wxService.getCodeService().getPage();
|
||||
System.out.println(String.valueOf(pageList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubmitAudit() throws Exception {
|
||||
WxMaCodeSubmitAuditRequest auditRequest = WxMaCodeSubmitAuditRequest
|
||||
.builder()
|
||||
.itemList(Arrays.asList(
|
||||
WxMaCategory
|
||||
.builder()
|
||||
.address("pages/logs/logs")
|
||||
.tag("工具 效率")
|
||||
.firstClass("工具")
|
||||
.firstId(287L)
|
||||
.secondClass("效率")
|
||||
.secondId(616L)
|
||||
.title("日志")
|
||||
.build()
|
||||
)).build();
|
||||
long auditId = wxService.getCodeService().submitAudit(auditRequest);
|
||||
assertTrue(auditId > 0);
|
||||
// 421937937
|
||||
System.out.println(auditId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAuditStatus() throws Exception {
|
||||
WxMaCodeAuditStatus auditStatus = wxService.getCodeService().getAuditStatus(421937937L);
|
||||
System.out.println(auditStatus);
|
||||
assertNotNull(auditStatus);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLatestAuditStatus() throws Exception {
|
||||
WxMaCodeAuditStatus auditStatus = wxService.getCodeService().getLatestAuditStatus();
|
||||
System.out.println(auditStatus);
|
||||
assertNotNull(auditStatus);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelease() throws Exception {
|
||||
wxService.getCodeService().release();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeVisitStatus() throws Exception {
|
||||
wxService.getCodeService().changeVisitStatus("open");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRevertCodeRelease() throws Exception {
|
||||
wxService.getCodeService().revertCodeRelease();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSupportVersion() throws Exception {
|
||||
WxMaCodeVersionDistribution distribution = wxService.getCodeService().getSupportVersion();
|
||||
System.out.println(distribution);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetSupportVersion() throws Exception {
|
||||
wxService.getCodeService().setSupportVersion("1.2.0");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUndoCodeAudit() throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.binarywang.wx.miniapp.bean.code;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/charmingoh">Charming</a>
|
||||
* @since 2018-04-26 19:54
|
||||
*/
|
||||
public class WxMaCodeCommitRequestTest {
|
||||
@Test
|
||||
public void testToJson() {
|
||||
WxMaCodeCommitRequest commitRequest = WxMaCodeCommitRequest.builder()
|
||||
.templateId(1L)
|
||||
.userVersion("v0.1.0")
|
||||
.userDesc("init")
|
||||
.extConfig(WxMaCodeExtConfig.builder()
|
||||
.extAppid("app123")
|
||||
.extEnable(true)
|
||||
.build())
|
||||
.build();
|
||||
assertEquals(commitRequest.toJson(), "{\"template_id\":1,\"user_version\":\"v0.1.0\",\"user_desc\":\"init\",\"ext_json\":\"{\\\"extEnable\\\":true,\\\"extAppid\\\":\\\"app123\\\"}\"}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.binarywang.wx.miniapp.bean.code;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/charmingoh">Charming</a>
|
||||
* @since 2018-04-26 19:55
|
||||
*/
|
||||
public class WxMaCodeSubmitAuditRequestTest {
|
||||
@Test
|
||||
public void testToJson() {
|
||||
WxMaCodeSubmitAuditRequest request = WxMaCodeSubmitAuditRequest
|
||||
.builder()
|
||||
.itemList(Arrays.asList(
|
||||
WxMaCategory
|
||||
.builder()
|
||||
.address("pages/logs/logs")
|
||||
.tag("工具 效率")
|
||||
.firstClass("工具")
|
||||
.firstId(287L)
|
||||
.secondClass("效率")
|
||||
.secondId(616L)
|
||||
.title("日志")
|
||||
.build()
|
||||
)).build();
|
||||
System.out.println(request.toJson());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.binarywang.wx.miniapp.bean.code;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/charmingoh">Charming</a>
|
||||
* @since 2018-04-26 19:58
|
||||
*/
|
||||
public class WxMaCodeVersionDistributionTest {
|
||||
@Test
|
||||
public void testFromJson() {
|
||||
String json = "{\"errcode\":0,\"errmsg\":\"ok\",\"now_version\":\"1.2.0\",\"uv_info\":{\"items\":[{\"version\":\"0.0.0\",\"percentage\":0},{\"version\":\"1.0.0\",\"percentage\":0},{\"version\":\"1.0.1\",\"percentage\":0},{\"version\":\"1.1.0\",\"percentage\":0},{\"version\":\"1.1.1\",\"percentage\":0},{\"version\":\"1.2.0\",\"percentage\":0},{\"version\":\"1.2.1\",\"percentage\":0},{\"version\":\"1.2.2\",\"percentage\":0},{\"version\":\"1.2.3\",\"percentage\":0},{\"version\":\"1.2.4\",\"percentage\":0},{\"version\":\"1.2.5\",\"percentage\":0},{\"version\":\"1.2.6\",\"percentage\":0},{\"version\":\"1.3.0\",\"percentage\":0},{\"version\":\"1.4.0\",\"percentage\":0},{\"version\":\"1.4.1\",\"percentage\":0},{\"version\":\"1.4.2\",\"percentage\":0},{\"version\":\"1.4.3\",\"percentage\":0},{\"version\":\"1.4.4\",\"percentage\":0},{\"version\":\"1.5.0\",\"percentage\":0},{\"version\":\"1.5.1\",\"percentage\":0},{\"version\":\"1.5.2\",\"percentage\":0},{\"version\":\"1.5.3\",\"percentage\":0},{\"version\":\"1.5.4\",\"percentage\":0},{\"version\":\"1.5.5\",\"percentage\":0},{\"version\":\"1.5.6\",\"percentage\":0},{\"version\":\"1.5.7\",\"percentage\":0},{\"version\":\"1.5.8\",\"percentage\":0},{\"version\":\"1.6.0\",\"percentage\":0.0132},{\"version\":\"1.6.1\",\"percentage\":0.0132},{\"version\":\"1.6.2\",\"percentage\":0.0132},{\"version\":\"1.6.3\",\"percentage\":0.0132},{\"version\":\"1.6.4\",\"percentage\":0.0132},{\"version\":\"1.6.5\",\"percentage\":0.0132},{\"version\":\"1.6.6\",\"percentage\":0.0132},{\"version\":\"1.6.7\",\"percentage\":0.1711},{\"version\":\"1.6.8\",\"percentage\":0.1711},{\"version\":\"1.7.0\",\"percentage\":0.1842},{\"version\":\"1.7.1\",\"percentage\":0.25},{\"version\":\"1.7.2\",\"percentage\":0.5263},{\"version\":\"1.7.3\",\"percentage\":0.5263},{\"version\":\"1.7.4\",\"percentage\":0.6711}]}}\n";
|
||||
System.out.println(WxMaCodeVersionDistribution.fromJson(json));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user