|
@@ -222,32 +222,51 @@ public class TokenController extends BaseController {
|
|
|
QRLoginDto dto = (QRLoginDto) data;
|
|
|
return HttpResponseResult.succeed(dto);
|
|
|
} else {
|
|
|
- return HttpResponseResult.failed("二维码已过期");
|
|
|
+ return HttpResponseResult.succeed("二维码已过期");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/qrLogin")
|
|
|
- @ApiOperation(value = "二维码登录")
|
|
|
+ @ApiOperation(value = "二维码登录-扫码")
|
|
|
public HttpResponseResult<QRLoginDto> qrLogin(
|
|
|
@ApiParam(value = "二维码登录code", required = true) @RequestParam("code") String code
|
|
|
) throws IOException {
|
|
|
+ AuthUser authUser = SecurityUtils.getUser();
|
|
|
+ if (authUser == null) {
|
|
|
+ return HttpResponseResult.failed("请先登录");
|
|
|
+ }
|
|
|
+ SysUser sysUser = userService.get(authUser.getUserId());
|
|
|
+
|
|
|
Object data = redissonClient.getBucket(CacheNameEnum.QR_LOGIN_CODE.getRedisKey(code))
|
|
|
.get();
|
|
|
if (null == data) {
|
|
|
return HttpResponseResult.failed("二维码已过期");
|
|
|
}
|
|
|
+ QRLoginDto dto = (QRLoginDto) data;
|
|
|
+ dto.setCodeStatus("scanned");
|
|
|
+ dto.setPhone(sysUser.getPhone());
|
|
|
+ dto.setUserType(authUser.getClientId().toUpperCase());
|
|
|
+ redissonClient.getBucket(CacheNameEnum.QR_LOGIN_CODE.getRedisKey(code)).set(dto, 5, TimeUnit.MINUTES);
|
|
|
+ return succeed(dto);
|
|
|
+ }
|
|
|
|
|
|
+ @GetMapping(value = "/doQrLogin")
|
|
|
+ @ApiOperation(value = "二维码登录-确认登录")
|
|
|
+ public HttpResponseResult<QRLoginDto> doQrLogin(
|
|
|
+ @ApiParam(value = "二维码登录code", required = true) @RequestParam("code") String code
|
|
|
+ ) throws IOException {
|
|
|
AuthUser authUser = SecurityUtils.getUser();
|
|
|
if (authUser == null) {
|
|
|
return HttpResponseResult.failed("请先登录");
|
|
|
}
|
|
|
SysUser sysUser = userService.get(authUser.getUserId());
|
|
|
|
|
|
+ Object data = redissonClient.getBucket(CacheNameEnum.QR_LOGIN_CODE.getRedisKey(code))
|
|
|
+ .get();
|
|
|
+ if (null == data) {
|
|
|
+ return HttpResponseResult.failed("二维码已过期");
|
|
|
+ }
|
|
|
QRLoginDto dto = (QRLoginDto) data;
|
|
|
- dto.setCodeStatus("scanned");
|
|
|
- dto.setPhone(sysUser.getPhone());
|
|
|
- dto.setUserType(authUser.getClientId().toUpperCase());
|
|
|
- redissonClient.getBucket(CacheNameEnum.QR_LOGIN_CODE.getRedisKey(code)).set(dto, 5, TimeUnit.MINUTES);
|
|
|
|
|
|
String url = "http://auth-server/smsLogin";
|
|
|
|
|
@@ -277,6 +296,6 @@ public class TokenController extends BaseController {
|
|
|
dto.setCodeStatus("filed");
|
|
|
}
|
|
|
redissonClient.getBucket(CacheNameEnum.QR_LOGIN_CODE.getRedisKey(code)).set(dto, 5, TimeUnit.MINUTES);
|
|
|
- return succeed(dto);
|
|
|
+ return HttpResponseResult.succeed(dto);
|
|
|
}
|
|
|
}
|