From 877f8651b86d233f7093aeeedc37b71af23f3f1d Mon Sep 17 00:00:00 2001 From: pikaqiudeshujia Date: Sat, 15 Jun 2024 15:04:09 +0800 Subject: [PATCH] =?UTF-8?q?release-=20=E7=94=9F=E6=88=90uuid=E6=97=B6?= =?UTF-8?q?=E5=AD=98=E5=85=A5=E7=BC=93=E5=AD=98=EF=BC=8C=E7=94=9F=E6=88=90?= =?UTF-8?q?=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=97=B6=E4=B9=9F=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=9C=89=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/luoo/user/controller/LoginController.java | 12 +++++++++++- .../java/com/luoo/user/service/UserInfoService.java | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java index 308e716..0a5f2c7 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/LoginController.java @@ -400,6 +400,7 @@ public class LoginController extends BaseController { @GetMapping(value = "/uuid") public Result getUuid() { String uuid = UUID.randomUUID().toString(); + redisTemplate.opsForValue().set(uuid, 0, 60, TimeUnit.SECONDS); return Result.success(uuid); } @@ -419,11 +420,20 @@ public class LoginController extends BaseController { response.setContentType("image/jpeg"); try { + + Object o = redisTemplate.opsForValue().get(uuid); + if (o == null) { + throw new BizException("二维码失效!"); + } + if(!String.valueOf(o).equals("0")) { + throw new BizException("登录认证已完成"); + } + response.setHeader("uuid", uuid); // 这里是开源工具类 hutool里的QrCodeUtil // 网址:http://hutool.mydoc.io/ QrCodeUtil.generate(uuid, 300, 300, "jpg",response.getOutputStream()); - redisTemplate.opsForValue().set(uuid, 0, 60, TimeUnit.SECONDS); + } catch (Exception e) { e.printStackTrace(); } diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java index 07ca002..317e802 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserInfoService.java @@ -715,7 +715,7 @@ public class UserInfoService { if (o == null) { throw new BizException("二维码失效!"); } - if(!String.valueOf(0).equals("0")) { + if(!String.valueOf(o).equals("0")) { throw new BizException("登录认证已完成"); }