|
@@ -586,12 +586,13 @@ public class LoginController {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 验证码登录
|
|
* 验证码登录
|
|
|
- *
|
|
|
|
|
|
|
+ * 2.4.15 版本后弃用
|
|
|
* @param phoneNumber
|
|
* @param phoneNumber
|
|
|
* @param code
|
|
* @param code
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/SMS_login")
|
|
@GetMapping("/SMS_login")
|
|
|
|
|
+ @Deprecated
|
|
|
public ResultVO userRegistrationAndSMSLogin(String phoneNumber, String code) {
|
|
public ResultVO userRegistrationAndSMSLogin(String phoneNumber, String code) {
|
|
|
String codeValue = redisTemplate.opsForValue().get(String.format(RedisConstant.SMS_PREFIX, phoneNumber));
|
|
String codeValue = redisTemplate.opsForValue().get(String.format(RedisConstant.SMS_PREFIX, phoneNumber));
|
|
|
if (!StringUtils.equals(codeValue, code)) {
|
|
if (!StringUtils.equals(codeValue, code)) {
|
|
@@ -640,6 +641,64 @@ public class LoginController {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @GetMapping("/SMS_login_from_type")
|
|
|
|
|
+ public ResultVO userRegistrationAndSMSLogin(String account, String code, Integer type) {
|
|
|
|
|
+ String codeValue = redisTemplate.opsForValue().get(String.format(RedisConstant.SMS_PREFIX, account));
|
|
|
|
|
+ if (!StringUtils.equals(codeValue, code)) {
|
|
|
|
|
+ log.warn("【code校验】Redis 中查找不到验证码 {},==,{}", codeValue, code);
|
|
|
|
|
+ return ResultVOUtil.error(UserEnum.USER_CODE_ERROR.getCode(), UserEnum.USER_CODE_ERROR.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("codeValue:" + codeValue);
|
|
|
|
|
+ //token
|
|
|
|
|
+ String token = UUID.randomUUID().toString();
|
|
|
|
|
+ Integer expire = RedisConstant.EXPIRE;//过期时间
|
|
|
|
|
+ Map<String, String> tokenMap = new HashMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ MainInfo mainInfo = null;
|
|
|
|
|
+ if(type.equals(0)){
|
|
|
|
|
+ mainInfo = mainInfoService.findMainInfoByPhoneNumber(account);
|
|
|
|
|
+ }else if(type.equals(1)){
|
|
|
|
|
+ mainInfo = mainInfoService.findMainInfoByEmail(account);
|
|
|
|
|
+ }
|
|
|
|
|
+ //TODO 验证码登录流程
|
|
|
|
|
+ //如果不存在用户
|
|
|
|
|
+ if (mainInfo == null) {
|
|
|
|
|
+ //先main_info主表添加信息
|
|
|
|
|
+ mainInfo = createMainInfo();
|
|
|
|
|
+ if(type.equals(0)){
|
|
|
|
|
+ mainInfo.setTelephoneNumber(account);
|
|
|
|
|
+ }else if(type.equals(1)){
|
|
|
|
|
+ mainInfo.setEmail(account);
|
|
|
|
|
+ }
|
|
|
|
|
+ mainInfoService.addMainInfo(mainInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ //TODO 写入成功后,删除redis里面保存的code
|
|
|
|
|
+ Boolean bSuccess = redisTemplate.delete(String.format(RedisConstant.SMS_PREFIX, account));
|
|
|
|
|
+ if (!bSuccess) {
|
|
|
|
|
+ //删除不成功,redis不存在
|
|
|
|
|
+ log.info("redis 没有对应的token");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ tokenMap.put("userId", mainInfo.getUserId());
|
|
|
|
|
+
|
|
|
|
|
+ redisTemplate.opsForHash().putAll(String.format(RedisConstant.TOKEN_PREFIX, token), tokenMap);
|
|
|
|
|
+ redisTemplate.expire(String.format(RedisConstant.TOKEN_PREFIX, token), expire, TimeUnit.SECONDS);
|
|
|
|
|
+
|
|
|
|
|
+ //返回一个token
|
|
|
|
|
+ LoginVO loginVO = new LoginVO();
|
|
|
|
|
+ loginVO.setToken(token);
|
|
|
|
|
+ loginVO.setNewUser(bUserInfoByUserId(mainInfo.getUserId()));
|
|
|
|
|
+ return ResultVOUtil.success(loginVO);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (UserException e) {
|
|
|
|
|
+
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
|
+ return ResultVOUtil.error(UserEnum.USER_REGISTER_ERROR.getCode(), UserEnum.USER_REGISTER_ERROR.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 密码登录
|
|
* 密码登录
|
|
|
* 2.4.10 版本后弃用
|
|
* 2.4.10 版本后弃用
|