|
|
@ -1,8 +1,10 @@
|
|
|
|
package com.mashibing.apipassenger.service;
|
|
|
|
package com.mashibing.apipassenger.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.mashibing.apipassenger.remote.ServicePassengerUserCLient;
|
|
|
|
import com.mashibing.apipassenger.remote.ServiceVerificationcodeClient;
|
|
|
|
import com.mashibing.apipassenger.remote.ServiceVerificationcodeClient;
|
|
|
|
import com.mashibing.internalcommon.constant.CommonStatusEnum;
|
|
|
|
import com.mashibing.internalcommon.constant.CommonStatusEnum;
|
|
|
|
import com.mashibing.internalcommon.dto.ResponseResult;
|
|
|
|
import com.mashibing.internalcommon.dto.ResponseResult;
|
|
|
|
|
|
|
|
import com.mashibing.internalcommon.request.VerificationCodeDTO;
|
|
|
|
import com.mashibing.internalcommon.response.NumberCodeResponse;
|
|
|
|
import com.mashibing.internalcommon.response.NumberCodeResponse;
|
|
|
|
import com.mashibing.internalcommon.response.TokenResponse;
|
|
|
|
import com.mashibing.internalcommon.response.TokenResponse;
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
@ -19,6 +21,11 @@ public class VerificationCodeService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ServiceVerificationcodeClient verificationcodeClient;
|
|
|
|
private ServiceVerificationcodeClient verificationcodeClient;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ServicePassengerUserCLient servicePassengerUserCLient;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
|
|
|
|
|
|
|
|
@ -50,7 +57,7 @@ public class VerificationCodeService {
|
|
|
|
* @param passengerPhone
|
|
|
|
* @param passengerPhone
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public ResponseResult checkCode(String passengerPhone,String verificationCode){
|
|
|
|
public ResponseResult checkCode(String passengerPhone,String verificationCode){
|
|
|
|
|
|
|
|
|
|
|
|
// 根据 key前缀+号码 从redis取出对应 校验码比较
|
|
|
|
// 根据 key前缀+号码 从redis取出对应 校验码比较
|
|
|
|
String redisKey = getRdisKey(passengerPhone);
|
|
|
|
String redisKey = getRdisKey(passengerPhone);
|
|
|
@ -60,7 +67,12 @@ public class VerificationCodeService {
|
|
|
|
if(StringUtils.isBlank(codeRedis) || !StringUtils.equals(codeRedis,verificationCode) ){
|
|
|
|
if(StringUtils.isBlank(codeRedis) || !StringUtils.equals(codeRedis,verificationCode) ){
|
|
|
|
return ResponseResult.fail(CommonStatusEnum.VERIFICATION_CODE_ERROR.getCode(), CommonStatusEnum.VERIFICATION_CODE_ERROR.getValue());
|
|
|
|
return ResponseResult.fail(CommonStatusEnum.VERIFICATION_CODE_ERROR.getCode(), CommonStatusEnum.VERIFICATION_CODE_ERROR.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 判断 登录手机号用户是否存在,不存在则注册登录
|
|
|
|
// 判断 登录手机号用户是否存在,不存在则注册登录
|
|
|
|
|
|
|
|
VerificationCodeDTO verificationCodeDTO = new VerificationCodeDTO();
|
|
|
|
|
|
|
|
verificationCodeDTO.setPassengerPhone(passengerPhone);
|
|
|
|
|
|
|
|
servicePassengerUserCLient.loginOrRegister(verificationCodeDTO);
|
|
|
|
|
|
|
|
redisTemplate.delete(redisKey);// 使用后删除key
|
|
|
|
|
|
|
|
|
|
|
|
// 颁布 token 令牌
|
|
|
|
// 颁布 token 令牌
|
|
|
|
TokenResponse tokenResponse = new TokenResponse();
|
|
|
|
TokenResponse tokenResponse = new TokenResponse();
|
|
|
|