🎨 #2474【小程序】createWxaCodeUnlimit 接口方法支持设置check_path参数

This commit is contained in:
穗苗子 2021-12-30 09:17:19 +08:00 committed by GitHub
parent 1309e9e2dc
commit a647fe8c5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 13 deletions

View File

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

View File

@ -76,24 +76,25 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
} }
@Override @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 { WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
return this.service.execute(QrcodeBytesRequestExecutor.create(this.service.getRequestHttp()), 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 @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 { WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp()), 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) { WxMaCodeLineColor lineColor, boolean isHyaline) {
WxaCodeUnlimit wxaCodeUnlimit = new WxaCodeUnlimit(); WxaCodeUnlimit wxaCodeUnlimit = new WxaCodeUnlimit();
wxaCodeUnlimit.setScene(scene); wxaCodeUnlimit.setScene(scene);
wxaCodeUnlimit.setPage(page); wxaCodeUnlimit.setPage(page);
wxaCodeUnlimit.setCheckPath(checkPath);
wxaCodeUnlimit.setEnvVersion(envVersion); wxaCodeUnlimit.setEnvVersion(envVersion);
wxaCodeUnlimit.setWidth(width); wxaCodeUnlimit.setWidth(width);
wxaCodeUnlimit.setAutoColor(autoColor); wxaCodeUnlimit.setAutoColor(autoColor);
@ -105,7 +106,7 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
@Override @Override
public File createWxaCodeUnlimit(String scene, String page) throws WxErrorException { 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 @Override
@ -144,15 +145,15 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
} }
@Override @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 { WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp(), filePath), 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 @Override
public File createWxaCodeUnlimit(String scene, String page, String filePath) throws WxErrorException { 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);
} }
} }

View File

@ -20,6 +20,9 @@ public class WxaCodeUnlimit extends AbstractWxMaQrcodeWrapper implements Seriali
private String scene; private String scene;
private String page; private String page;
@SerializedName("check_path")
private boolean checkPath = true;
@SerializedName("env_version") @SerializedName("env_version")
private String envVersion = "release"; private String envVersion = "release";

View File

@ -52,7 +52,7 @@ public class WxMaQrcodeServiceImplTest {
@Test @Test
public void testCreateWxaCodeUnlimitBytes() throws WxErrorException { 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(); assertThat(wxCode).isNotNull();
} }