|
|
@ -400,6 +400,7 @@ public class LoginController extends BaseController {
|
|
|
|
@GetMapping(value = "/uuid")
|
|
|
|
@GetMapping(value = "/uuid")
|
|
|
|
public Result<String> getUuid() {
|
|
|
|
public Result<String> getUuid() {
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(uuid, 0, 60, TimeUnit.SECONDS);
|
|
|
|
return Result.success(uuid);
|
|
|
|
return Result.success(uuid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -419,11 +420,20 @@ public class LoginController extends BaseController {
|
|
|
|
response.setContentType("image/jpeg");
|
|
|
|
response.setContentType("image/jpeg");
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
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);
|
|
|
|
response.setHeader("uuid", uuid);
|
|
|
|
// 这里是开源工具类 hutool里的QrCodeUtil
|
|
|
|
// 这里是开源工具类 hutool里的QrCodeUtil
|
|
|
|
// 网址:http://hutool.mydoc.io/
|
|
|
|
// 网址:http://hutool.mydoc.io/
|
|
|
|
QrCodeUtil.generate(uuid, 300, 300, "jpg",response.getOutputStream());
|
|
|
|
QrCodeUtil.generate(uuid, 300, 300, "jpg",response.getOutputStream());
|
|
|
|
redisTemplate.opsForValue().set(uuid, 0, 60, TimeUnit.SECONDS);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|