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

“20191025 修改手机号接口

上级 30ac8a7c
流水线 #16333 已失败 于阶段
in 0 second
......@@ -7,9 +7,14 @@ import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.req.PatientReq;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.RSAUtil;
import org.springframework.boot.autoconfigure.SpringBootApplication;
public class Test {
public static void main(String[] args) throws Exception {
// String json="{\"key\":\"密钥\",\"content\": {\"mobilePhone\" : \"1302412588\", \"flag\": \"1\"}}\n" +
// " }";
......@@ -49,7 +54,6 @@ public class Test {
// EncryptEntity patientReqEncryptEntity = new EncryptEntity();
// patientReqEncryptEntity.setContent(json);
// System.out.println(JSONObject.toJSONString(patientReqEncryptEntity));
// Doctor doctor = new Doctor();
// doctor.setName("crs");
// doctor.setMobilePhone("13024112222");
......@@ -58,11 +62,9 @@ public class Test {
// doctor.setCityName("上海市");
// String doctorJson = JSONObject.toJSONString(doctor);
// System.out.println(doctorJson);
// String mobile = jsonObject.getString("mobile");
// String authCode = jsonObject.getString("authCode");
// String password = jsonObject.getString("password");
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("mobile","13024112565");
// jsonObject.put("authCode","13024112565");
......@@ -105,7 +107,7 @@ public class Test {
System.out.println("--------------------获取验证码接口-------------");
BaseRequest authCode = new BaseRequest();
authCode.setFlag(5);
authCode.setFlag(3);
authCode.setMobile("13024112092");
String authCodeStr = JSONObject.toJSONString(authCode);
System.out.println(authCodeStr);
......@@ -174,9 +176,24 @@ public class Test {
encryptTest9.setKey(keyResult9);
System.out.println(JSONObject.toJSONString(encryptTest9));
System.out.println("--------------------修改手机号-------------");
BaseRequest changeMobile = new BaseRequest();
changeMobile.setMobile("13024112092");
changeMobile.setAuthCode("623849");
String string1 = JSONObject.toJSONString(changeMobile);
System.out.println(string1);
String changeMobileContent = AESUtil.aesEncrypt(string1, "YCPQPx4qpQjEjDea");
String changeMobileKey = RSAUtil.encrypt("YCPQPx4qpQjEjDea",publicKey);
EncryptEntity changeMobileEntity = new EncryptEntity();
changeMobileEntity.setKey(changeMobileKey);
changeMobileEntity.setContent(changeMobileContent);
System.out.println(JSONObject.toJSONString(changeMobileEntity));
}
}
......@@ -24,6 +24,7 @@ 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.apache.ibatis.logging.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -151,6 +152,7 @@ public class AutoCodeController extends AccountBaseController {
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobilePhone);
long senderId = accountInfoEntity == null ? 0L : accountInfoEntity.getId();
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag.toString()), authCode, 600);
logger.info("验证码缓存信息----->:"+this.getAuthCodeKey(mobilePhone, flag.toString()));
cacheClient.set(authCodeKeySecure, System.currentTimeMillis(), 60);
super.sendMobileMessage(mobilePhone, message, senderId);
}
......
......@@ -3,9 +3,12 @@ package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.AccountInfoService;
import com.pica.cloud.account.account.server.service.DoctorService;
import com.pica.cloud.account.account.server.service.ModifyMobileService;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.entity.PicaResponse;
......@@ -29,12 +32,14 @@ public class ModifyMobileController extends AccountBaseController {
@Autowired
private DoctorService doctorService;
@ApiOperation("修改手机号")
@PostMapping("/mobile/modify")
public PicaResponse modifyMobile(@RequestBody EncryptEntity entity) throws Exception {
Long doctorId = super.getDoctorIdByToken();
Doctor doctorInfo = doctorService.getDoctorInfo(doctorId.intValue());
Integer acctId = doctorInfo.getAcctId();
String mobilePhone = doctorInfo.getMobilePhone();
Integer acctId = modifyMobileService.getAcctIdByMobile(mobilePhone);
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
String mobile = request.getMobile();
accountUtils.checkMobilePhoneAndAuthCode(mobile, AccountTypeEnum.SYSCODE_TYPE_MODIFY_MOBILE.getCode() + "", request.getAuthCode());
......
......@@ -10,4 +10,7 @@ public interface ModifyMobileService {
* @param mobile 手机号
*/
void modify(Integer acctId, String mobile);
Integer getAcctIdByMobile(String phone);
}
......@@ -58,4 +58,10 @@ public class ModifyMobileServiceImpl implements ModifyMobileService {
}
}
@Override
public Integer getAcctIdByMobile(String phone) {
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(phone);
return accountInfoEntity.getId();
}
}
......@@ -22,6 +22,16 @@ public class AESUtil {
//算法
private static final String ALGORITHMSTR = "AES/ECB/PKCS5Padding";
public static final String privateKey="MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJrqPdInBev+ksvBvo+rymL1K0+r5" +
"a+bq+74tZAHWE2oKVaTSNCbkacXoqPRpzaCqCwyy61zeGExppfZBm8tf6AVAcL+58YF0Fuk+0N4ZaxAi2wx//GqqWQs+Rzt5VPJ+yaulAzs" +
"Eb0tW9o9Vc9VRxl8k0Fpi5Hj5J/pmLZrIj+FAgMBAAECgYAj+0A8rZ+sfsat2ORgDnDFp1hV+wEwVqIKsW3KdEpIT0S6vR7uhRPBkbXPAwU" +
"pnhNdoLa6JNXTDWs6XcgmzpSTx32WS3450+h1QNdLL+doiEinWxGijvp+UN7CadoeFBnLml3gGjPpTMeDheialQExwwvVKKe4+0VjO4zPDG" +
"nrAQJBAM3luGYrweNcFxvVsfQG6cpR/C0DeykyojN0Kbq+3/S+wG1y53Ak1HKz4OHftC4liYNXWy9W1fQ/MSbdVaSka+UCQQDAnJmYwmJ64" +
"I35T+GmgA0r505BCuYZG9pNyrjdko7n5+DaalRWSXuAwXb2SJbFHvWmVEgZOnVRhPdFgZUGP4shAkAjmG1SrInuhoMwOrdzGqbcZWQVXB60" +
"tp44CwMT19/b7gZSZaUBTDy2P8bHBeeeerrVTArlmjuO6EXVFDq0JgDJAkBLlCdhHcVu2fZbwdCVeOGyPI0kUJaBe8BpjgaESyHwNbixe8+" +
"kHCluGHwJn+opZ0CVB7VS0PGAD2DH0VUcooqBAkEAvLBZTnNcM/I2xbV6euw9gpEw7uLkT/94McLQOuZjKPWPHKDQOqa+y+CRPYuxIhQsFK" +
"mlTze7cR+/4QUANvGAow==";
/**
* aes解密
* @param encrypt 内容
......@@ -156,14 +166,41 @@ public class AESUtil {
* 测试
*/
public static void main(String[] args) throws Exception {
String KEY="zJJ$c5md3$yuuhWW";
String content = "apepJUvpShKMmbMMLl6wiA==";
System.out.println("加密前:" + content);
System.out.println("加密密钥和解密密钥:" + KEY);
String encrypt = aesEncrypt(content, KEY);
System.out.println("加密后:" + encrypt);
String decrypt = aesDecrypt(encrypt, KEY);
System.out.println("解密后:" + decrypt);
// String KEY="zJJ$c5md3$yuuhWW";
// System.out.println("-------------加密---------");
// String content = "apepJUvpShKMmbMMLl6wiA==";
// System.out.println("加密前:" + content);
// System.out.println("加密密钥和解密密钥:" + KEY);
//
// System.out.println("-------------解密---------");
// String encrypt = aesEncrypt(content, KEY);
// System.out.println("加密后:" + encrypt);
// String decrypt = aesDecrypt(encrypt, KEY);
// System.out.println("解密后:" + decrypt);
//请求参数解密处理
String encrypt="mkYDBWaW0EsWboHLGZYP7ANcXrUsm8pz553zJaUsRTKdzJPSU5bMRklcpiIcxQxy2RaCxmyBckVA+ECk2C7HfSS/iZgs/BwwKjvNWLSMu3aKmeBGfbhIhXQoroj8Q0fX7DZM/NLc15CXwWNcXVn0RnU0l+T0HHHtwNG6gPz9LpU=";
String decrypt = RSAUtil.decrypt(encrypt,privateKey);
System.out.println(decrypt);
//System.out.println("YCPQPx4qpQjEjDea");
String content="knx6jN8noH4ay0pRiTyVCCGInoN31ouglRTrtjmX9u/y1y7ogTmpfUBYsvz5WtZi";
String result = AESUtil.aesDecrypt(content, decrypt);
System.out.println(result);
}
}
package com.pica.cloud.account.account.server.util;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.controller.AccountController;
import com.pica.cloud.account.account.server.entity.AccountPatientInfoEntity;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
......@@ -11,6 +12,8 @@ import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.ValidateUtils;
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.stereotype.Component;
......@@ -25,6 +28,8 @@ public class AccountUtils {
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient;
private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Autowired
private AccountPatientInfoMapper accountPatientInfoMapper;
......@@ -83,9 +88,13 @@ public class AccountUtils {
String authCodeKey = AccountUtils.getAuthCodeKey(mobile, flag);
//验证码3次校验测试不通过,直接删除
String authCodeCount = AUTH_CODE_COUNT_PREFIX + flag + "-" + AESUtil.encryptV0(mobile);
logger.info("验证码缓存信息----->:"+this.getAuthCodeKey(mobile, flag));
if (cacheClient.exists(authCodeCount) && Integer.parseInt(cacheClient.get(authCodeCount)) > 2) {
cacheClient.del(authCodeKey);
}
String cacheCode = cacheClient.get(authCodeKey); //从redis获取验证码
if (org.apache.commons.lang.StringUtils.isBlank(cacheCode)) {
//第四次删除计数器
......
......@@ -24,12 +24,12 @@ import java.util.Map;
public class RSAUtil {
private static Map<Integer, String> keyMap = new HashMap<>();
private static String rsaprivatekey;
public static String rsaprivatekey;
public static String rsapublickey;
@Value("${rsaprivatekey}")
private String rsaprivatekeyTemp;
public String rsaprivatekeyTemp;
@Value("${rsapublickey}")
public String rsapublickeyTemp;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册