APP下载放行
This commit is contained in:
parent
cee2b0bdca
commit
68ce3e9b15
@ -34,6 +34,7 @@ public class AppFilter implements Filter {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AppFilter.class);
|
||||
private AntPathMatcher antPathMatcher;
|
||||
private static final String URL_LOGIN = "/app/sign/login";
|
||||
private static final String URL_DOWNLOAD_APP = "/app/appversion/downloadapp/**";
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
@ -45,7 +46,7 @@ public class AppFilter implements Filter {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse) servletResponse;
|
||||
String requestUri = request.getRequestURI();
|
||||
if (antPathMatcher.match(URL_LOGIN, requestUri)) {
|
||||
if (antPathMatcher.match(URL_LOGIN, requestUri) || antPathMatcher.match(URL_DOWNLOAD_APP, requestUri)) {
|
||||
filterChain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
|
@ -0,0 +1,86 @@
|
||||
package com.cm.common.utils;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
|
||||
public class QRCodeUtil {
|
||||
|
||||
public static BufferedImage createQrCode(int width, int height, String content, String logoPath) {
|
||||
Map<EncodeHintType, Object> qrParams = new HashMap<>(3);
|
||||
// 编码
|
||||
qrParams.put(EncodeHintType.CHARACTER_SET, "UTF-8");
|
||||
// 纠错等级
|
||||
qrParams.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
|
||||
// 边框
|
||||
qrParams.put(EncodeHintType.MARGIN, 1);
|
||||
// 生成二维码
|
||||
BufferedImage bufferedImage = null;
|
||||
try {
|
||||
BitMatrix bitMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE,
|
||||
width, height);
|
||||
bufferedImage = getBufferImage(bitMatrix);
|
||||
if (null != logoPath && !logoPath.isEmpty()) {
|
||||
addLogo(bufferedImage, logoPath);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return bufferedImage;
|
||||
}
|
||||
|
||||
private static BufferedImage getBufferImage(BitMatrix bitMatrix) {
|
||||
int bmWidth = bitMatrix.getWidth();
|
||||
int bmHeight = bitMatrix.getHeight();
|
||||
BufferedImage bufferedImage = new BufferedImage(bmWidth, bmHeight,
|
||||
BufferedImage.TYPE_INT_ARGB);
|
||||
for (int x = 0; x < bmWidth; x++) {
|
||||
for (int y = 0; y < bmHeight; y++) {
|
||||
bufferedImage.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
return bufferedImage;
|
||||
}
|
||||
|
||||
private static void addLogo(BufferedImage bufferedImage, String logoPath) throws IOException {
|
||||
Graphics2D graphics2d = bufferedImage.createGraphics();
|
||||
Image logo = ImageIO.read(new File(logoPath));
|
||||
// 设置比例
|
||||
int logoWidth = bufferedImage.getWidth() / 6;
|
||||
int logoHeight = bufferedImage.getHeight() / 6;
|
||||
|
||||
// 填充logo
|
||||
int x = bufferedImage.getWidth() / 2 - logoWidth / 2;
|
||||
int y = bufferedImage.getHeight() / 2 - logoHeight / 2;
|
||||
// 设置抗锯齿
|
||||
graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
// 填充填充背景
|
||||
graphics2d.setColor(Color.WHITE);
|
||||
graphics2d.fillRoundRect(x, y, logoWidth, logoHeight, 10, 10);
|
||||
|
||||
// 画边框
|
||||
graphics2d.setColor(new Color(220, 220, 220));
|
||||
graphics2d.drawRoundRect(x, y, logoWidth, logoHeight, 10, 10);
|
||||
|
||||
// 画LOGO
|
||||
graphics2d.drawImage(logo, x + 2, y + 2, logoWidth - 4, logoHeight - 4, null);
|
||||
graphics2d.dispose();
|
||||
logo.flush();
|
||||
}
|
||||
|
||||
}
|
9
pom.xml
9
pom.xml
@ -52,8 +52,8 @@
|
||||
<thumbnailator.version>0.4.8</thumbnailator.version>
|
||||
<mysql.version>5.1.47</mysql.version>
|
||||
<jedis.version>2.9.0</jedis.version>
|
||||
|
||||
<swagger.version>2.5.0</swagger.version>
|
||||
<zxing.version>3.3.3</zxing.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -309,6 +309,13 @@
|
||||
<version>${swagger.version}</version>
|
||||
</dependency>
|
||||
<!-- swagger end -->
|
||||
<!-- zxing start -->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>${zxing.version}</version>
|
||||
</dependency>
|
||||
<!-- zxing end -->
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
|
Loading…
Reference in New Issue
Block a user