Commit dcf2bcb3 by songxiang
parents 7bf01732 90a817e2
......@@ -215,6 +215,33 @@ public class QrcodeUtils {
}
/**
* 创建二维码
*
* @param url
* 二维码响应地址
* @return
* @throws Exception
*/
public static String createWithMargin(String url, Integer marginNum) throws BizException {
LOGGER.info("【二维码】创建二维码,<START>.[url]=" + url);
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>();
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.ERROR_CORRECTION, level);
hints.put(EncodeHintType.MARGIN, marginNum); // 设置白边
try {
// 生成矩阵
BitMatrix bitMatrix = new MultiFormatWriter().encode(url, BarcodeFormat.QR_CODE, ImageConstant.QRCODE_WITH,
ImageConstant.QRCODE_HEIGHT, hints);
BufferedImage bufferedImage = toBufferedImage(bitMatrix, onColor);
bufferedImage.flush();
return uploadImage(bufferedImage);
} catch (Exception e) {
LOGGER.error("【二维码】创建二维码失败,<ERROR>:" + e.getMessage(), e);
throw new FileException(FileException.FILE_UPLOAD_FAILURE, "创建二维码失败");
}
}
/**
* 创建带颜色的二维码
* @param url
* @param onColor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment