Skip to content

Commit

Permalink
🎨 #2386 【小程序】createWxaCodeUnlimit 接口方法支持设置env_string
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwenjie authored Dec 5, 2021
1 parent a254d1c commit 05ea881
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,18 @@ File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLineColor
* 调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 urlencode
* </pre>
*
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
* @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
* @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码
* @return 文件内容字节数组
* @throws WxErrorException 异常
*/
byte[] createWxaCodeUnlimitBytes(String scene, String page, int width, boolean autoColor,
byte[] createWxaCodeUnlimitBytes(String scene, String page, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;

/**
Expand All @@ -212,18 +213,19 @@ byte[] createWxaCodeUnlimitBytes(String scene, String page, int width, boolean a
* 调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 urlencode
* </pre>
*
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param filePath 二维码生成的文件路径,例如: /var/temp
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
* @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param filePath 二维码生成的文件路径,例如: /var/temp
* @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
* @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码
* @return 文件对象
* @throws WxErrorException 异常
*/
File createWxaCodeUnlimit(String scene, String page, String filePath, int width, boolean autoColor,
File createWxaCodeUnlimit(String scene, String page, String filePath, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;

/**
Expand All @@ -235,17 +237,18 @@ File createWxaCodeUnlimit(String scene, String page, String filePath, int width,
* 调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 urlencode
* </pre>
*
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
* @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码
* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
* 其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
* @param page 必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
* @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
* @param width 默认430 二维码的宽度
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
* @param isHyaline 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码
* @return 文件对象
* @throws WxErrorException 异常
*/
File createWxaCodeUnlimit(String scene, String page, int width, boolean autoColor,
File createWxaCodeUnlimit(String scene, String page, String envVersion, int width, boolean autoColor,
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;

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

@Override
public byte[] createWxaCodeUnlimitBytes(String scene, String page, int width, boolean autoColor,
public byte[] createWxaCodeUnlimitBytes(String scene, String page, 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, width, autoColor, lineColor, isHyaline));
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, envVersion, width, autoColor, lineColor, isHyaline));
}

@Override
public File createWxaCodeUnlimit(String scene, String page, int width, boolean autoColor,
public File createWxaCodeUnlimit(String scene, String page, 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, width, autoColor, lineColor, isHyaline));
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, envVersion, width, autoColor, lineColor, isHyaline));
}

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

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

@Override
Expand Down Expand Up @@ -143,15 +144,15 @@ public File createWxaCode(String path, String filePath) throws WxErrorException
}

@Override
public File createWxaCodeUnlimit(String scene, String page, String filePath, int width, boolean autoColor,
public File createWxaCodeUnlimit(String scene, String page, String filePath, 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, width, autoColor, lineColor, isHyaline));
GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, envVersion, width, autoColor, lineColor, isHyaline));
}

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

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

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

private int width = 430;

@SerializedName("auto_color")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testCreateWxaCodeBytes() throws WxErrorException {

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

Expand Down

0 comments on commit 05ea881

Please sign in to comment.