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("登录认证已完成"); }