From 2e94b68420cb2cb88826958dfb6c34fad694d0d3 Mon Sep 17 00:00:00 2001 From: qizhenxin Date: Wed, 10 Apr 2024 22:08:24 +0800 Subject: [PATCH] feat : a --- .../controller/VerifyController.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/qzx/xdupartner/controller/VerifyController.java b/src/main/java/com/qzx/xdupartner/controller/VerifyController.java index 674ffdf..19868ac 100644 --- a/src/main/java/com/qzx/xdupartner/controller/VerifyController.java +++ b/src/main/java/com/qzx/xdupartner/controller/VerifyController.java @@ -103,20 +103,30 @@ public R sendCode(@RequestParam("stuId") String stuId) { @ApiOperation("") @GetMapping("/testLogin") public R testLogin(@RequestParam("stuId") String stuId) { - String sessionKey = "12345678"; - if (stuId.equals(sessionKey)) { + String sessionKey1 = "12345678"; + String sessionKey2 = "123456789"; + if (stuId.equals(sessionKey1)) { User user = userService.lambdaQuery().eq(User::getId, 35).one(); - if (ObjectUtil.isNull(user)) { - return null; + return getStringR(sessionKey1, user); + } else if (stuId.equals(sessionKey2)) { + if (stuId.equals(sessionKey2)) { + User user = userService.lambdaQuery().eq(User::getId, 14).one(); + return getStringR(sessionKey2, user); } - user.setSessionKey(sessionKey); - stringRedisTemplate.opsForValue().set(RedisConstant.LOGIN_PREFIX + sessionKey, - JSONUtil.toJsonStr(user), - RedisConstant.LOGIN_VALID_TTL, - TimeUnit.DAYS); - return new R<>(ResultCode.SUCCESS, sessionKey); } return new R<>(ResultCode.FAILED, ""); } + private R getStringR(String sessionKey2, User user) { + if (ObjectUtil.isNull(user)) { + return null; + } + user.setSessionKey(sessionKey2); + stringRedisTemplate.opsForValue().set(RedisConstant.LOGIN_PREFIX + sessionKey2, + JSONUtil.toJsonStr(user), + RedisConstant.LOGIN_VALID_TTL, + TimeUnit.DAYS); + return new R<>(ResultCode.SUCCESS, sessionKey2); + } + }