Skip to content

Commit

Permalink
🎨 #2474【小程序】createWxaCodeUnlimit 接口方法支持设置check_path参数
Browse files Browse the repository at this point in the history
suimz authored Dec 30, 2021
1 parent 1309e9e commit a647fe8
Showing 4 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -193,6 +193,8 @@ File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLineColor
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param checkPath 默认true 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);
* 为 false 时允许小程序未发布或者 page 不存在,但 page 有数量上限(60000个)请勿滥用
* @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
@@ -201,7 +203,7 @@ File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLineColor
* @return 文件内容字节数组
* @throws WxErrorException 异常
*/
byte[] createWxaCodeUnlimitBytes(String scene, String page, String envVersion, int width, boolean autoColor,
byte[] createWxaCodeUnlimitBytes(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;

/**
@@ -217,6 +219,8 @@ byte[] createWxaCodeUnlimitBytes(String scene, String page, String envVersion, i
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param filePath 二维码生成的文件路径,例如: /var/temp
* @param checkPath 默认true 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);
* 为 false 时允许小程序未发布或者 page 不存在,但 page 有数量上限(60000个)请勿滥用
* @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
@@ -225,7 +229,7 @@ byte[] createWxaCodeUnlimitBytes(String scene, String page, String envVersion, i
* @return 文件对象
* @throws WxErrorException 异常
*/
File createWxaCodeUnlimit(String scene, String page, String filePath, String envVersion, int width, boolean autoColor,
File createWxaCodeUnlimit(String scene, String page, String filePath, boolean checkPath, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;

/**
@@ -240,6 +244,8 @@ File createWxaCodeUnlimit(String scene, String page, String filePath, String env
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param checkPath 默认true 检查 page 是否存在,为 true 时 page 必须是已经发布的小程序存在的页面(否则报错);
* 为 false 时允许小程序未发布或者 page 不存在,但 page 有数量上限(60000个)请勿滥用
* @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
@@ -248,7 +254,7 @@ File createWxaCodeUnlimit(String scene, String page, String filePath, String env
* @return 文件对象
* @throws WxErrorException 异常
*/
File createWxaCodeUnlimit(String scene, String page, String envVersion, int width, boolean autoColor,
File createWxaCodeUnlimit(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;

/**
Original file line number Diff line number Diff line change
@@ -76,24 +76,25 @@ public File createWxaCode(String path) throws WxErrorException {
}

@Override
public byte[] createWxaCodeUnlimitBytes(String scene, String page, String envVersion, int width, boolean autoColor,
public byte[] createWxaCodeUnlimitBytes(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
return this.service.execute(QrcodeBytesRequestExecutor.create(this.service.getRequestHttp()),
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, envVersion, width, autoColor, lineColor, isHyaline));
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
}

@Override
public File createWxaCodeUnlimit(String scene, String page, String envVersion, int width, boolean autoColor,
public File createWxaCodeUnlimit(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp()),
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, envVersion, width, autoColor, lineColor, isHyaline));
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
}

private WxaCodeUnlimit buildWxaCodeUnlimit(String scene, String page, String envVersion, int width, boolean autoColor,
private WxaCodeUnlimit buildWxaCodeUnlimit(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) {
WxaCodeUnlimit wxaCodeUnlimit = new WxaCodeUnlimit();
wxaCodeUnlimit.setScene(scene);
wxaCodeUnlimit.setPage(page);
wxaCodeUnlimit.setCheckPath(checkPath);
wxaCodeUnlimit.setEnvVersion(envVersion);
wxaCodeUnlimit.setWidth(width);
wxaCodeUnlimit.setAutoColor(autoColor);
@@ -105,7 +106,7 @@ private WxaCodeUnlimit buildWxaCodeUnlimit(String scene, String page, String env

@Override
public File createWxaCodeUnlimit(String scene, String page) throws WxErrorException {
return this.createWxaCodeUnlimit(scene, page, "release", 430, true, null, false);
return this.createWxaCodeUnlimit(scene, page, true, "release", 430, true, null, false);
}

@Override
@@ -144,15 +145,15 @@ public File createWxaCode(String path, String filePath) throws WxErrorException
}

@Override
public File createWxaCodeUnlimit(String scene, String page, String filePath, String envVersion, int width, boolean autoColor,
public File createWxaCodeUnlimit(String scene, String page, String filePath, boolean checkPath, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp(), filePath),
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, envVersion, width, autoColor, lineColor, isHyaline));
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
}

@Override
public File createWxaCodeUnlimit(String scene, String page, String filePath) throws WxErrorException {
return this.createWxaCodeUnlimit(scene, page, filePath, "release", 430, true, null, false);
return this.createWxaCodeUnlimit(scene, page, filePath, true, "release", 430, true, null, false);
}

}
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ public class WxaCodeUnlimit extends AbstractWxMaQrcodeWrapper implements Seriali
private String scene;
private String page;

@SerializedName("check_path")
private boolean checkPath = true;

@SerializedName("env_version")
private String envVersion = "release";

Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ public void testCreateWxaCodeBytes() throws WxErrorException {

@Test
public void testCreateWxaCodeUnlimitBytes() throws WxErrorException {
final byte[] wxCode = this.wxService.getQrcodeService().createWxaCodeUnlimitBytes("111", null, "trial", 122, true, null, false);
final byte[] wxCode = this.wxService.getQrcodeService().createWxaCodeUnlimitBytes("111", "pages/unknown", false, "trial", 122, true, null, false);
assertThat(wxCode).isNotNull();
}

0 comments on commit a647fe8

Please sign in to comment.