提交 d8678e11 编写于 作者: rushui.chen's avatar rushui.chen

20191022 解决bug

上级 0c9cebe2
流水线 #16172 已失败 于阶段
in 0 second
......@@ -15,15 +15,16 @@ public class Test {
// " }";
//获取验证码参数
// BaseRequest request = new BaseRequest();
// request.setFlag(1);
// request.setMobile("13024112588");
// String string = JSONObject.toJSONString(request);
// System.out.println(string);
// EncryptEntity encryptEntity = new EncryptEntity();
// encryptEntity.setContent(string);
// System.out.println(JSONObject.toJSONString(encryptEntity));
// System.out.println("------------------------------>");
BaseRequest request = new BaseRequest();
request.setFlag(1);
request.setMobile("13024112070");
String string = JSONObject.toJSONString(request);
System.out.println(string);
EncryptEntity encryptEntity = new EncryptEntity();
encryptEntity.setContent(string);
System.out.println(JSONObject.toJSONString(encryptEntity));
System.out.println("------------------------------>");
//获取注册参数
// BaseRequest register = null;
......@@ -79,7 +80,7 @@ public class Test {
System.out.println("--------------------登录接口-------------");
String publicKey="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCa6j3SJwXr/pLLwb6Pq8pi9StPq+Wvm6vu+LWQB1hNqClWk0jQm5GnF6Kj0ac2gqgsMsutc3hhMaaX2QZvLX+gFQHC/ufGBdBbpPtDeGWsQItsMf/xqqlkLPkc7eVTyfsmrpQM7BG9LVvaPVXPVUcZfJNBaYuR4+Sf6Zi2ayI/hQIDAQAB";
BaseRequest login = new BaseRequest();
login.setMobile("13024112062");
login.setMobile("13024112080");
login.setPassword("D0DCBF0D12A6B1E7FBFA2CE5848F3EFF");
String con = JSONObject.toJSONString(login);
String contentResult = AESUtil.aesEncrypt(con, "YCPQPx4qpQjEjDea");
......@@ -94,12 +95,60 @@ public class Test {
changePwd.setOldPwd("D0DCBF0D12A6B1E7FBFA2CE5848F3EFF");
changePwd.setPassword("0B9A75D6A88721A4BCF94F0FD668C56B");
String changePwdStr = JSONObject.toJSONString(changePwd);
System.out.println(changePwdStr);
String contentResult1 = AESUtil.aesEncrypt(changePwdStr, "YCPQPx4qpQjEjDea");
String keyResult1 = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity encryptTest1 = new EncryptEntity();
encryptTest1.setContent(contentResult1);
encryptTest1.setKey(keyResult1);
System.out.println(JSONObject.toJSONString(encryptTest1));
System.out.println("--------------------获取验证码接口-------------");
BaseRequest authCode = new BaseRequest();
authCode.setFlag(1);
authCode.setMobile("13024112081");
String authCodeStr = JSONObject.toJSONString(authCode);
System.out.println(authCodeStr);
String contentResult2 = AESUtil.aesEncrypt(authCodeStr, "YCPQPx4qpQjEjDea");
String keyResult2 = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity encryptTest2 = new EncryptEntity();
encryptTest2.setContent(contentResult2);
encryptTest2.setKey(keyResult2);
System.out.println(JSONObject.toJSONString(encryptTest2));
System.out.println("--------------------注册接口-------------");
//获取注册参数
BaseRequest register = null;
register = new BaseRequest();
register.setMobile("13024112080");
register.setPassword("D0DCBF0D12A6B1E7FBFA2CE5848F3EFF");
register.setAuthCode("012082");
String registerString3 = JSONObject.toJSONString(register);
String contentResult3 = AESUtil.aesEncrypt(registerString3, "YCPQPx4qpQjEjDea");
String keyResult3 = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity encryptTest3 = new EncryptEntity();
encryptTest3.setContent(contentResult3);
encryptTest3.setKey(keyResult3);
System.out.println(JSONObject.toJSONString(encryptTest3));
System.out.println("--------------------一键登录接口-------------");
BaseRequest loginRegister = null;
loginRegister = new BaseRequest();
loginRegister.setMobile("13024112081");
loginRegister.setAuthCode("393791");
String registerString4 = JSONObject.toJSONString(loginRegister);
String contentResult4 = AESUtil.aesEncrypt(registerString4, "YCPQPx4qpQjEjDea");
String keyResult4 = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity encryptTest4 = new EncryptEntity();
encryptTest4.setContent(contentResult4);
encryptTest4.setKey(keyResult4);
System.out.println(JSONObject.toJSONString(encryptTest4));
}
......
......@@ -120,7 +120,7 @@ public class AccountController extends AccountBaseController {
this.checkAuthCode(req);
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
Account account = new Account();
account.setMobilePhone(req.getMobilePhone());
account.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE));
switch (deviceType) { //注册来源
case "1":
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_3); //pc
......@@ -150,11 +150,11 @@ public class AccountController extends AccountBaseController {
public PicaResponse loginRegister(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
this.checkMobilePhone(request.getMobile());
AccountReq req = new AccountReq();
req.setMobilePhone(request.getMobile());
req.setPassword(null);//登录或注册,只能使用验证码
req.setAuthCode(request.getAuthCode());
req.setFlag("1");
req.setUnionid(request.getUnionId());
//判断账号是否已经存在
......@@ -181,6 +181,7 @@ public class AccountController extends AccountBaseController {
//获取验证码redis key
private String getAuthCodeKey(String mobilePhone, String flag) {
logger.info(AUTH_CODE_PREFIX + flag + "-" + EncryptUtils.encryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE));
return AUTH_CODE_PREFIX + flag + "-" + EncryptUtils.encryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE);
}
......@@ -193,7 +194,9 @@ public class AccountController extends AccountBaseController {
}
String authCodeKey = this.getAuthCodeKey(req.getMobilePhone(), flag);
logger.info(authCodeKey);
String cacheCode = redisClient.get(authCodeKey); //从redis获取验证码
if (StringUtils.isBlank(cacheCode)) {
throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已过期,请重新获取");
}
......@@ -285,7 +288,7 @@ public class AccountController extends AccountBaseController {
this.checkAuthCode(req);
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
Account account = new Account();
account.setMobilePhone(req.getMobilePhone());
account.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE));
switch (deviceType) { //注册来源
case "1":
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_3); //pc
......
......@@ -24,6 +24,8 @@ import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -36,6 +38,7 @@ import org.springframework.web.bind.annotation.RestController;
public class AutoCodeController extends AccountBaseController {
private final String AUTH_CODE_PREFIX = "authCode-";
private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
......@@ -83,6 +86,7 @@ public class AutoCodeController extends AccountBaseController {
long senderId = account == null ? 0L : account.getId();
//验证码保存到redis,失效时间10分钟
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag), authCode, 600);
logger.info(this.getAuthCodeKey(mobilePhone, flag));
//发送短信
super.sendMobileMessage(mobilePhone, message, senderId);
return PicaResponse.toResponse(StringUtils.EMPTY);
......
......@@ -69,6 +69,7 @@ public class AccountServiceImpl implements AccountService {
//账户表
AccountInfoEntity accountInfo = new AccountInfoEntity();
Date currentTime = new Date();
accountInfo.setMobilePhone(account.getMobilePhone());
accountInfo.setPassword("");
accountInfo.setCreatedTime(currentTime);
accountInfo.setCreatedId(0);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册