Merge branch 'refs/heads/master' into 支付优化测试
This commit is contained in:
		| @ -911,17 +911,17 @@ public class MemberUserServiceImpl implements MemberUserService { | ||||
|     @Override | ||||
|     public String getQRCode() { | ||||
|         Long userId = getLoginUserId(); | ||||
|         String redisKey = QRCodeWithJWTUtil.QR_PREFIX+userId; | ||||
|         String url = memberUserRedisTemplate.opsForValue().get(redisKey); | ||||
|         if(StrUtil.isNotEmpty(url)){ | ||||
|             return url; | ||||
|         } | ||||
| //        String redisKey = QRCodeWithJWTUtil.QR_PREFIX+userId; | ||||
| //        String url = memberUserRedisTemplate.opsForValue().get(redisKey); | ||||
| //        if(StrUtil.isNotEmpty(url)){ | ||||
| //            return url; | ||||
| //        } | ||||
|         String encode = DigestUtil.md5Hex(userId.toString()+System.currentTimeMillis()); | ||||
|         String fileName = "QRCode_" + userId + ".png"; | ||||
|         String path = QRCodeWithJWTUtil.BASE_PATH+fileName; | ||||
|         QRCodeWithJWTUtil.generateQRCode(encode, 350, 350, path); // 生 | ||||
|         memberUserRedisTemplate.opsForValue().set(redisKey,path,180, TimeUnit.SECONDS); | ||||
|         String s = QRCodeWithJWTUtil.generateQRCode(encode, 350, 350, path);// 生 | ||||
| //        memberUserRedisTemplate.opsForValue().set(redisKey,path,180, TimeUnit.SECONDS); | ||||
|         memberUserRedisTemplate.opsForValue().set(encode,userId.toString(),180, TimeUnit.SECONDS); | ||||
|         return path; | ||||
|         return s; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -9,9 +9,13 @@ import cn.hutool.json.JSONUtil; | ||||
| import cn.hutool.jwt.JWTUtil; | ||||
|  | ||||
|  | ||||
| import javax.imageio.ImageIO; | ||||
| import java.awt.image.BufferedImage; | ||||
| import java.io.ByteArrayOutputStream; | ||||
| import java.io.File; | ||||
|  | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.Base64; | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| @ -47,8 +51,18 @@ public class QRCodeWithJWTUtil { | ||||
|     } | ||||
|  | ||||
|     // 生成二维码图片 | ||||
|     public static void generateQRCode(String data, int width, int height, String filePath)  { | ||||
|         QrCodeUtil.generate(data, width, height, new File(filePath)); | ||||
|     public static String generateQRCode(String data, int width, int height, String filePath)  { | ||||
|         BufferedImage generate = QrCodeUtil.generate(data, width, height); | ||||
|  | ||||
|         try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { | ||||
|             ImageIO.write(generate, "png", baos); | ||||
|             byte[] imageBytes = baos.toByteArray(); | ||||
|             return "data:image/png;base64," + Base64.getEncoder().encodeToString(imageBytes); | ||||
|         } catch (Exception e) { | ||||
|             e.printStackTrace(); | ||||
|             return null; | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|     // 验证JWT是否有效和未过期 | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 seesaw
					seesaw