mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-11-04 06:07:59 +08:00 
			
		
		
		
	🎨 #2386 【小程序】createWxaCodeUnlimit 接口方法支持设置env_string
This commit is contained in:
		@ -193,6 +193,7 @@ public interface WxMaQrcodeService {
 | 
				
			|||||||
   * @param scene      最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
 | 
					   * @param scene      最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
 | 
				
			||||||
   *                   其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
 | 
					   *                   其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
 | 
				
			||||||
   * @param page       必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
 | 
					   * @param page       必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
 | 
				
			||||||
 | 
					   * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
 | 
				
			||||||
   * @param width      默认430 二维码的宽度
 | 
					   * @param width      默认430 二维码的宽度
 | 
				
			||||||
   * @param autoColor  默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
 | 
					   * @param autoColor  默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
 | 
				
			||||||
   * @param lineColor  autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
 | 
					   * @param lineColor  autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
 | 
				
			||||||
@ -200,7 +201,7 @@ public interface WxMaQrcodeService {
 | 
				
			|||||||
   * @return 文件内容字节数组
 | 
					   * @return 文件内容字节数组
 | 
				
			||||||
   * @throws WxErrorException 异常
 | 
					   * @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;
 | 
					                                   WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
@ -216,6 +217,7 @@ public interface WxMaQrcodeService {
 | 
				
			|||||||
   *                   其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
 | 
					   *                   其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
 | 
				
			||||||
   * @param page       必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
 | 
					   * @param page       必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
 | 
				
			||||||
   * @param filePath   二维码生成的文件路径,例如: /var/temp
 | 
					   * @param filePath   二维码生成的文件路径,例如: /var/temp
 | 
				
			||||||
 | 
					   * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
 | 
				
			||||||
   * @param width      默认430 二维码的宽度
 | 
					   * @param width      默认430 二维码的宽度
 | 
				
			||||||
   * @param autoColor  默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
 | 
					   * @param autoColor  默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
 | 
				
			||||||
   * @param lineColor  autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
 | 
					   * @param lineColor  autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
 | 
				
			||||||
@ -223,7 +225,7 @@ public interface WxMaQrcodeService {
 | 
				
			|||||||
   * @return 文件对象
 | 
					   * @return 文件对象
 | 
				
			||||||
   * @throws WxErrorException 异常
 | 
					   * @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;
 | 
					                            WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
@ -238,6 +240,7 @@ public interface WxMaQrcodeService {
 | 
				
			|||||||
   * @param scene      最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
 | 
					   * @param scene      最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,
 | 
				
			||||||
   *                   其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
 | 
					   *                   其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)
 | 
				
			||||||
   * @param page       必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
 | 
					   * @param page       必须是已经发布的小程序页面,例如 "pages/index/index" ,如果不填写这个字段,默认跳主页面
 | 
				
			||||||
 | 
					   * @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
 | 
				
			||||||
   * @param width      默认430 二维码的宽度
 | 
					   * @param width      默认430 二维码的宽度
 | 
				
			||||||
   * @param autoColor  默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
 | 
					   * @param autoColor  默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
 | 
				
			||||||
   * @param lineColor  autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
 | 
					   * @param lineColor  autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
 | 
				
			||||||
@ -245,7 +248,7 @@ public interface WxMaQrcodeService {
 | 
				
			|||||||
   * @return 文件对象
 | 
					   * @return 文件对象
 | 
				
			||||||
   * @throws WxErrorException 异常
 | 
					   * @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;
 | 
					                            WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
 | 
				
			|||||||
@ -76,24 +76,25 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Override
 | 
					  @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 {
 | 
					                                          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, width, autoColor, lineColor, isHyaline));
 | 
					      GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, envVersion, width, autoColor, lineColor, isHyaline));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Override
 | 
					  @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 {
 | 
					                                   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, 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) {
 | 
					                                             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.setEnvVersion(envVersion);
 | 
				
			||||||
    wxaCodeUnlimit.setWidth(width);
 | 
					    wxaCodeUnlimit.setWidth(width);
 | 
				
			||||||
    wxaCodeUnlimit.setAutoColor(autoColor);
 | 
					    wxaCodeUnlimit.setAutoColor(autoColor);
 | 
				
			||||||
    wxaCodeUnlimit.setLineColor(lineColor);
 | 
					    wxaCodeUnlimit.setLineColor(lineColor);
 | 
				
			||||||
@ -104,7 +105,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, 430, true, null, false);
 | 
					    return this.createWxaCodeUnlimit(scene, page, "release", 430, true, null, false);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Override
 | 
					  @Override
 | 
				
			||||||
@ -143,15 +144,15 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Override
 | 
					  @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 {
 | 
					                                   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, width, autoColor, lineColor, isHyaline));
 | 
					      GET_WXACODE_UNLIMIT_URL, this.buildWxaCodeUnlimit(scene, page, 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, 430, true, null, false);
 | 
					    return this.createWxaCodeUnlimit(scene, page, filePath, "release", 430, true, null, false);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,9 @@ public class WxaCodeUnlimit extends AbstractWxMaQrcodeWrapper implements Seriali
 | 
				
			|||||||
  private String scene;
 | 
					  private String scene;
 | 
				
			||||||
  private String page;
 | 
					  private String page;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @SerializedName("env_version")
 | 
				
			||||||
 | 
					  private String envVersion = "release";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private int width = 430;
 | 
					  private int width = 430;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @SerializedName("auto_color")
 | 
					  @SerializedName("auto_color")
 | 
				
			||||||
 | 
				
			|||||||
@ -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, 122, true, null, false);
 | 
					    final byte[] wxCode = this.wxService.getQrcodeService().createWxaCodeUnlimitBytes("111", null, "trial", 122, true, null, false);
 | 
				
			||||||
    assertThat(wxCode).isNotNull();
 | 
					    assertThat(wxCode).isNotNull();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user