mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 【小程序】获取小程序码的createWxaCode相关接口支持envVersion参数
This commit is contained in:
@@ -101,45 +101,48 @@ public interface WxMaQrcodeService {
|
||||
/**
|
||||
* 接口A: 获取小程序码.
|
||||
*
|
||||
* @param path 不能为空,最大长度 128 字节
|
||||
* @param width 默认430 二维码的宽度
|
||||
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
|
||||
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
|
||||
* @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码
|
||||
* @param path 不能为空,最大长度 128 字节
|
||||
* @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 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码
|
||||
* @return 文件内容字节数组
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
byte[] createWxaCodeBytes(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
|
||||
throws WxErrorException;
|
||||
byte[] createWxaCodeBytes(String path, String envVersion, int width, boolean autoColor, WxMaCodeLineColor lineColor,
|
||||
boolean isHyaline) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 接口A: 获取小程序码.
|
||||
*
|
||||
* @param path 不能为空,最大长度 128 字节
|
||||
* @param width 默认430 二维码的宽度
|
||||
* @param filePath 二维码生成的文件路径,例如: /var/temp
|
||||
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
|
||||
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
|
||||
* @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码
|
||||
* @param path 不能为空,最大长度 128 字节
|
||||
* @param envVersion 默认"release" 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
|
||||
* @param width 默认430 二维码的宽度
|
||||
* @param filePath 二维码生成的文件路径,例如: /var/temp
|
||||
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
|
||||
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
|
||||
* @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码
|
||||
* @return 文件对象
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
File createWxaCode(String path, int width, String filePath, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
|
||||
throws WxErrorException;
|
||||
File createWxaCode(String path, String envVersion, int width, String filePath, boolean autoColor,
|
||||
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 接口A: 获取小程序码.
|
||||
*
|
||||
* @param path 不能为空,最大长度 128 字节
|
||||
* @param width 默认430 二维码的宽度
|
||||
* @param autoColor 默认true 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调
|
||||
* @param lineColor autoColor 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
|
||||
* @param isHyaline 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码
|
||||
* @param path 不能为空,最大长度 128 字节
|
||||
* @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 是否需要透明底色, isHyaline 为true时,生成透明底色的小程序码
|
||||
* @return 文件对象
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
|
||||
throws WxErrorException;
|
||||
File createWxaCode(String path, String envVersion, int width, boolean autoColor, WxMaCodeLineColor lineColor,
|
||||
boolean isHyaline) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 接口A: 获取小程序码.
|
||||
@@ -229,8 +232,8 @@ public interface WxMaQrcodeService {
|
||||
* @return 文件对象
|
||||
* @throws WxErrorException 异常
|
||||
*/
|
||||
File createWxaCodeUnlimit(String scene, String page, String filePath, boolean checkPath, String envVersion, int width, boolean autoColor,
|
||||
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;
|
||||
File createWxaCodeUnlimit(String scene, String page, String filePath, boolean checkPath, String envVersion, int width,
|
||||
boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 接口B: 获取小程序码(永久有效、数量暂无限制).
|
||||
|
||||
@@ -10,10 +10,12 @@ import cn.binarywang.wx.miniapp.executor.QrcodeBytesRequestExecutor;
|
||||
import cn.binarywang.wx.miniapp.executor.QrcodeRequestExecutor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaApiUrlConstants.Qrcode.*;
|
||||
import static cn.binarywang.wx.miniapp.constant.WxMaConstants.DEFAULT_ENV_VERSION;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
@@ -40,11 +42,12 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createWxaCodeBytes(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
|
||||
throws WxErrorException {
|
||||
public byte[] createWxaCodeBytes(String path, String envVersion, int width, boolean autoColor,
|
||||
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
|
||||
return this.service.execute(QrcodeBytesRequestExecutor.create(this.service.getRequestHttp()), GET_WXACODE_URL,
|
||||
WxaCode.builder()
|
||||
.path(path)
|
||||
.envVersion(StringUtils.defaultIfEmpty(envVersion, DEFAULT_ENV_VERSION))
|
||||
.width(width)
|
||||
.autoColor(autoColor)
|
||||
.lineColor(lineColor)
|
||||
@@ -53,11 +56,12 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File createWxaCode(String path, int width, boolean autoColor, WxMaCodeLineColor lineColor, boolean isHyaline)
|
||||
throws WxErrorException {
|
||||
public File createWxaCode(String path, String envVersion, int width, boolean autoColor, WxMaCodeLineColor lineColor,
|
||||
boolean isHyaline) throws WxErrorException {
|
||||
return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp()), GET_WXACODE_URL,
|
||||
WxaCode.builder()
|
||||
.path(path)
|
||||
.envVersion(StringUtils.defaultIfEmpty(envVersion, DEFAULT_ENV_VERSION))
|
||||
.width(width)
|
||||
.autoColor(autoColor)
|
||||
.lineColor(lineColor)
|
||||
@@ -67,7 +71,7 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
|
||||
|
||||
@Override
|
||||
public File createWxaCode(String path, int width) throws WxErrorException {
|
||||
return this.createWxaCode(path, width, true, null, false);
|
||||
return this.createWxaCode(path, null, width, true, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,21 +80,22 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] createWxaCodeUnlimitBytes(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor,
|
||||
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
|
||||
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, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
|
||||
}
|
||||
|
||||
@Override
|
||||
public File createWxaCodeUnlimit(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor,
|
||||
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
|
||||
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, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
|
||||
}
|
||||
|
||||
private WxaCodeUnlimit buildWxaCodeUnlimit(String scene, String page, boolean checkPath, String envVersion, int width, boolean autoColor,
|
||||
WxMaCodeLineColor lineColor, boolean isHyaline) {
|
||||
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);
|
||||
@@ -106,7 +111,7 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
|
||||
|
||||
@Override
|
||||
public File createWxaCodeUnlimit(String scene, String page) throws WxErrorException {
|
||||
return this.createWxaCodeUnlimit(scene, page, true, "release", 430, true, null, false);
|
||||
return this.createWxaCodeUnlimit(scene, page, true, DEFAULT_ENV_VERSION, 430, true, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,12 +126,12 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File createWxaCode(String path, int width, String filePath, boolean autoColor, WxMaCodeLineColor lineColor,
|
||||
boolean isHyaline)
|
||||
throws WxErrorException {
|
||||
public File createWxaCode(String path, String envVersion, int width, String filePath, boolean autoColor,
|
||||
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
|
||||
return this.service.execute(QrcodeRequestExecutor.create(this.service.getRequestHttp(), filePath), GET_WXACODE_URL,
|
||||
WxaCode.builder()
|
||||
.path(path)
|
||||
.envVersion(StringUtils.defaultIfEmpty(envVersion, DEFAULT_ENV_VERSION))
|
||||
.width(width)
|
||||
.autoColor(autoColor)
|
||||
.lineColor(lineColor)
|
||||
@@ -136,7 +141,7 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
|
||||
|
||||
@Override
|
||||
public File createWxaCode(String path, int width, String filePath) throws WxErrorException {
|
||||
return this.createWxaCode(path, width, filePath, true, null, false);
|
||||
return this.createWxaCode(path, null, width, filePath, true, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -145,15 +150,16 @@ public class WxMaQrcodeServiceImpl implements WxMaQrcodeService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public File createWxaCodeUnlimit(String scene, String page, String filePath, boolean checkPath, String envVersion, int width, boolean autoColor,
|
||||
WxMaCodeLineColor lineColor, boolean isHyaline) throws WxErrorException {
|
||||
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, checkPath, envVersion, width, autoColor, lineColor, isHyaline));
|
||||
}
|
||||
|
||||
@Override
|
||||
public File createWxaCodeUnlimit(String scene, String page, String filePath) throws WxErrorException {
|
||||
return this.createWxaCodeUnlimit(scene, page, filePath, true, "release", 430, true, null, false);
|
||||
return this.createWxaCodeUnlimit(scene, page, filePath, true, DEFAULT_ENV_VERSION, 430, true, null, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user