release- 扫码登录新增已扫码未登录状态

release-2024-08-08
huangyawei 4 months ago
parent c6aa15cfe6
commit 183731df5d

@ -44,7 +44,6 @@ import java.util.concurrent.TimeUnit;
*
*
* @author Administrator
*
*/
@RestController
@CrossOrigin
@ -139,6 +138,7 @@ public class LoginController extends BaseController {
redisTemplate.delete(redisMobileCheckCodeKey);
return Result.success(token);
}
@ApiOperation(value = "2.1 appleId登录/注册", notes = "成功后返回authorization")
@PostMapping("/appleIdLogin")
public Result<String> appleIdLogin(HttpServletRequest request, @VerifyParam AppleLoginReq appleLoginReq) {
@ -173,7 +173,6 @@ public class LoginController extends BaseController {
return Result.success(token);
}
@ApiOperation(value = "2.2 微信wxId登录/注册", notes = "成功后返回authorization")
@ -286,7 +285,6 @@ public class LoginController extends BaseController {
// }
/**
* authorization
*/
@ -318,8 +316,10 @@ public class LoginController extends BaseController {
redisTemplate.opsForValue().set(redisKey, code, 10, TimeUnit.MINUTES);
vCode.write(response.getOutputStream());
}
/**
* 4.1Base64
*
* @return
*/
@ApiOperation(value = "4.1获取图形验证码Base64", notes = "4.三次短信验证失败后获取图形验证码Base64有效期10分钟")
@ -349,8 +349,10 @@ public class LoginController extends BaseController {
public Result<List<CountryCodeDTO>> getSupportedCountryCode() {
return Result.success(DEFAULT_SUPPORTED_COUNTRY_CODES);
}
/**
* 退
*
* @param authorization
* @return
*/
@ -404,7 +406,7 @@ public class LoginController extends BaseController {
return Result.success(uuid);
}
@ApiOperation(value = "9.2.校验uuid对应的请求认证状态", notes = "0是未完成,其余是已完成状态的token")
@ApiOperation(value = "9.2.校验uuid对应的请求认证状态", notes = "0-未完成 1-已扫码 other-token")
@GetMapping(value = "/check/qr")
public Result<String> getCountryCode(String uuid) {
return Result.success(redisTemplate.opsForValue().get(uuid).toString());
@ -440,11 +442,13 @@ public class LoginController extends BaseController {
}
@ApiOperation(value = "9.4.确认身份接口:确定身份以及判断是否二维码过期等", notes = "确认身份接口:确定身份以及判断是否二维码过期等")
@PostMapping(value = "/bindUserIdAndToken")
public Result<String> bindUserIdAndToken(@RequestParam("token") String token ,
@RequestParam("userId") String userId){
@PostMapping(value = "/scanOrConfirm")
public Result<Void> scanOrConfirm(@RequestParam("token") String token,
@RequestParam("userId") String userId,
@RequestParam("type") Integer type) {
try {
return Result.success(userInfoService.bindUserIdAndToken(userId,token));
userInfoService.scan(userId, token, type);
return Result.success();
} catch (Exception e) {
throw new RuntimeException(e);
}

@ -710,7 +710,15 @@ public class UserInfoService {
userInfoDao.save(userInfoByUserName);
}
public String bindUserIdAndToken(String userId, String token) throws Exception {
/**
*
*
* @param userId id
* @param token uuid
* @param type 1- 2-
* @return token
*/
public void scan(String userId, String token, Integer type) throws Exception {
Object o = redisTemplate.opsForValue().get(token);
if (o == null) {
throw new BizException("二维码失效!");
@ -719,9 +727,15 @@ public class UserInfoService {
throw new BizException("登录认证已完成");
}
if(type == 1) {
// 扫码
redisTemplate.opsForValue().set(token, 1, 60, TimeUnit.SECONDS);
} else {
// 确认
UserInfo loginUserInfo = userInfoDao.findById(userId).get();
String authorization = loginOrRegister(loginUserInfo);
redisTemplate.opsForValue().set(token, authorization, 60, TimeUnit.SECONDS);
return authorization;
}
}
}

Loading…
Cancel
Save