提交 3c20b981 编写于 作者: dong.an's avatar dong.an

Merge branch 'dev-20190827-account-center' of...

Merge branch 'dev-20190827-account-center' of http://192.168.110.53/com.pica.cloud.account/pica-cloud-account into dev-20190827-account-center
流水线 #14748 已失败 于阶段
in 0 second
...@@ -56,6 +56,17 @@ public class Test { ...@@ -56,6 +56,17 @@ public class Test {
String doctorJson = JSONObject.toJSONString(doctor); String doctorJson = JSONObject.toJSONString(doctor);
System.out.println(doctorJson); 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");
jsonObject.put("password","qq123456");
System.out.println(jsonObject.toJSONString());
} }
......
...@@ -3,14 +3,12 @@ package com.pica.cloud.account.account.server.controller; ...@@ -3,14 +3,12 @@ package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.AccountUser; import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.entity.Doctor; import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.service.DoctorService; import com.pica.cloud.account.account.server.service.DoctorService;
import com.pica.cloud.account.account.server.util.AccountUtils; import com.pica.cloud.account.account.server.util.AccountUtils;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants; import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils; import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
......
package com.pica.cloud.account.account.server.controller; package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.entity.AccountUnionEntity; import com.pica.cloud.account.account.server.entity.AccountUnionEntity;
import com.pica.cloud.account.account.server.entity.EncryptEntity; 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.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; 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.req.BaseRequest;
import com.pica.cloud.account.account.server.service.AccountUnionService; import com.pica.cloud.account.account.server.service.AccountUnionService;
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.AccountUtils;
import com.pica.cloud.account.account.server.util.CryptoUtil; import com.pica.cloud.account.account.server.util.CryptoUtil;
import com.pica.cloud.foundation.entity.PicaResponse; import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.CommonUtil; import com.pica.cloud.foundation.utils.utils.CommonUtil;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -97,20 +94,33 @@ public class SysCodeController extends AccountBaseController { ...@@ -97,20 +94,33 @@ public class SysCodeController extends AccountBaseController {
if (remainTime > 0) { if (remainTime > 0) {
throw new AccountException(AccountExceptionEnum.PICA_SYSCODE_RETRY.getCode(), throw new AccountException(AccountExceptionEnum.PICA_SYSCODE_RETRY.getCode(),
AccountExceptionEnum.PICA_SYSCODE_RETRY.getMessage().replace("X", String.valueOf(remainTime))); AccountExceptionEnum.PICA_SYSCODE_RETRY.getMessage().replace("X", String.valueOf(remainTime)));
} else {
processSendAuthCode(mobilePhone, flag, authCodeKeySecure);
} }
} else { } else {
String authCode = CommonUtil.createValidateCode(); processSendAuthCode(mobilePhone, flag, authCodeKeySecure);
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobilePhone);
long senderId = accountInfoEntity == null ? 0L : accountInfoEntity.getId();
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag.toString()), authCode, 600);
cacheClient.set(authCodeKeySecure, System.currentTimeMillis(), 60);
super.sendMobileMessage(mobilePhone, message, senderId);
} }
} }
/**
* 调用发送验证码的接口
*
* @param mobilePhone
* @param flag
* @param authCodeKeySecure
*/
private void processSendAuthCode(String mobilePhone, Integer flag, String authCodeKeySecure) {
String authCode = CommonUtil.createValidateCode();
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobilePhone);
long senderId = accountInfoEntity == null ? 0L : accountInfoEntity.getId();
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag.toString()), authCode, 600);
cacheClient.set(authCodeKeySecure, System.currentTimeMillis(), 60);
super.sendMobileMessage(mobilePhone, message, senderId);
}
//获取验证码redis key //获取验证码redis key
private String getAuthCodeKey(String mobilePhone, String flag) { private String getAuthCodeKey(String mobilePhone, String flag) {
return AUTH_CODE_PREFIX + flag + "-" + EncryptCreateUtil.encrypt(mobilePhone); return AUTH_CODE_PREFIX + flag + "-" + AESUtil.encryptV0(mobilePhone);
} }
} }
...@@ -2,7 +2,6 @@ package com.pica.cloud.account.account.server.log; ...@@ -2,7 +2,6 @@ package com.pica.cloud.account.account.server.log;
import com.pica.cloud.account.account.server.entity.LogLoginEntity; import com.pica.cloud.account.account.server.entity.LogLoginEntity;
import com.pica.cloud.account.account.server.entity.LogPWDModifyEntity; import com.pica.cloud.account.account.server.entity.LogPWDModifyEntity;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import java.util.Date; import java.util.Date;
...@@ -57,7 +56,7 @@ public class AccountLogEntityUtils { ...@@ -57,7 +56,7 @@ public class AccountLogEntityUtils {
entity.setModifiedTime(currentTime); entity.setModifiedTime(currentTime);
entity.setMobilePhone(mobile); entity.setMobilePhone(mobile);
entity.setOldPwd(oldpwd); entity.setOldPwd(oldpwd);
entity.setNewPwd(EncryptCreateUtil.encrypt(newPwd)); entity.setNewPwd(newPwd);
entity.setLogType(logType); entity.setLogType(logType);
return entity; return entity;
} }
......
...@@ -8,7 +8,6 @@ import com.pica.cloud.account.account.server.service.AccountService; ...@@ -8,7 +8,6 @@ import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants; import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils; import com.pica.cloud.foundation.encryption.util.EncryptUtils;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
......
...@@ -7,12 +7,7 @@ import com.pica.cloud.account.account.server.exception.AccountException; ...@@ -7,12 +7,7 @@ import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper; import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.service.DoctorService; import com.pica.cloud.account.account.server.service.DoctorService;
import com.pica.cloud.foundation.entity.PicaException; import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import microsoft.exchange.webservices.data.core.IFileAttachmentContentHandler;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -58,7 +53,7 @@ public class DoctorServiceImpl implements DoctorService { ...@@ -58,7 +53,7 @@ public class DoctorServiceImpl implements DoctorService {
@Transactional @Transactional
public void addDoctorInfo(Doctor doctor, Integer userId) { public void addDoctorInfo(Doctor doctor, Integer userId) {
String mobilePhone = doctor.getMobilePhone(); String mobilePhone = doctor.getMobilePhone();
String mobileEncrypt = EncryptCreateUtil.encrypt(mobilePhone); String mobileEncrypt = AESUtil.encryptV0(mobilePhone);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
if (accountInfoEntity != null) { if (accountInfoEntity != null) {
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER); throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
......
...@@ -12,17 +12,16 @@ import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; ...@@ -12,17 +12,16 @@ import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.AccountUnionMapper; import com.pica.cloud.account.account.server.mapper.AccountUnionMapper;
import com.pica.cloud.account.account.server.mapper.AccountWeChatInfoMapper; import com.pica.cloud.account.account.server.mapper.AccountWeChatInfoMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper; import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.req.AccountReq;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.DoctorService; import com.pica.cloud.account.account.server.service.DoctorService;
import com.pica.cloud.account.account.server.service.LoginService; import com.pica.cloud.account.account.server.service.LoginService;
import com.pica.cloud.account.account.server.service.RegisterService; import com.pica.cloud.account.account.server.service.RegisterService;
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.AccountUtils;
import com.pica.cloud.account.account.server.util.TokenUtils; import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.account.account.server.util.WeChatUtils; import com.pica.cloud.account.account.server.util.WeChatUtils;
import com.pica.cloud.foundation.entity.PicaException; import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -84,7 +83,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -84,7 +83,7 @@ public class LoginServiceImpl implements LoginService {
@Override @Override
public String login(BaseRequest request) { public String login(BaseRequest request) {
String mobile = request.getMobile(); String mobile = request.getMobile();
String encrypt = EncryptCreateUtil.encrypt(mobile); String encrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(encrypt); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(encrypt);
if (accountInfoEntity != null) { if (accountInfoEntity != null) {
String oldPwd = accountInfoEntity.getPassword(); String oldPwd = accountInfoEntity.getPassword();
...@@ -126,7 +125,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -126,7 +125,7 @@ public class LoginServiceImpl implements LoginService {
@Override @Override
public String loginAndRegister(BaseRequest baseRequest) { public String loginAndRegister(BaseRequest baseRequest) {
String mobile = baseRequest.getMobile(); String mobile = baseRequest.getMobile();
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(EncryptCreateUtil.encrypt(mobile)); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile));
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
return registerService.register(baseRequest); return registerService.register(baseRequest);
} else { } else {
...@@ -207,7 +206,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -207,7 +206,7 @@ public class LoginServiceImpl implements LoginService {
@Override @Override
public String loginByWeChatStep(BaseRequest request) { public String loginByWeChatStep(BaseRequest request) {
//判断当前手机号是否注册过,注册过,直接登录;没有注册过,进行注册操操作 //判断当前手机号是否注册过,注册过,直接登录;没有注册过,进行注册操操作
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(EncryptCreateUtil.encrypt(request.getMobile())); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
String json; String json;
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
json = registerService.register(request); json = registerService.register(request);
...@@ -225,7 +224,7 @@ public class LoginServiceImpl implements LoginService { ...@@ -225,7 +224,7 @@ public class LoginServiceImpl implements LoginService {
} else { } else {
json = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode()); json = processLogin(request, accountInfoEntity.getId(), AccountTypeEnum.LOGIN_WE_CHAT.getCode());
} }
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(EncryptCreateUtil.encrypt(request.getMobile())); AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
Integer acctId = accountInfo.getId(); Integer acctId = accountInfo.getId();
processAccountUnion(acctId, request.getUnionId()); processAccountUnion(acctId, request.getUnionId());
return json; return json;
......
...@@ -7,7 +7,7 @@ import com.pica.cloud.account.account.server.exception.AccountException; ...@@ -7,7 +7,7 @@ import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper; import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.service.ModifyMobileService; import com.pica.cloud.account.account.server.service.ModifyMobileService;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil; import com.pica.cloud.account.account.server.util.AESUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -33,14 +33,14 @@ public class ModifyMobileServiceImpl implements ModifyMobileService { ...@@ -33,14 +33,14 @@ public class ModifyMobileServiceImpl implements ModifyMobileService {
public void modify(Integer acctId, String mobile) { public void modify(Integer acctId, String mobile) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByPrimaryKey(acctId); AccountInfoEntity entity = accountInfoDetailMapper.selectByPrimaryKey(acctId);
String mobilePhone = entity.getMobilePhone(); String mobilePhone = entity.getMobilePhone();
if (StringUtils.isNotEmpty(mobilePhone) && EncryptCreateUtil.dencrypt(mobilePhone).equals(mobile)) { if (StringUtils.isNotEmpty(mobilePhone) && AESUtil.decryptV0(mobilePhone).equals(mobile)) {
throw new AccountException(AccountExceptionEnum.PICA_MOBILE_SAME); throw new AccountException(AccountExceptionEnum.PICA_MOBILE_SAME);
} }
AccountInfoEntity accountInfoEntity = new AccountInfoEntity(); AccountInfoEntity accountInfoEntity = new AccountInfoEntity();
accountInfoEntity.setId(acctId); accountInfoEntity.setId(acctId);
accountInfoEntity.setModifiedId(acctId); accountInfoEntity.setModifiedId(acctId);
accountInfoEntity.setModifiedTime(new Date()); accountInfoEntity.setModifiedTime(new Date());
accountInfoEntity.setMobilePhone(EncryptCreateUtil.encrypt(mobile)); accountInfoEntity.setMobilePhone(AESUtil.encryptV0(mobile));
accountInfoDetailMapper.updateMobileByPrimaryKey(accountInfoEntity); accountInfoDetailMapper.updateMobileByPrimaryKey(accountInfoEntity);
if (doubleWritingMode) { if (doubleWritingMode) {
//更新p_doctor表中用户的手机号 //更新p_doctor表中用户的手机号
...@@ -49,7 +49,7 @@ public class ModifyMobileServiceImpl implements ModifyMobileService { ...@@ -49,7 +49,7 @@ public class ModifyMobileServiceImpl implements ModifyMobileService {
doctor.setAcctId(acctId); doctor.setAcctId(acctId);
doctor.setModifyTime(currentTime); doctor.setModifyTime(currentTime);
doctor.setModifyId(acctId); doctor.setModifyId(acctId);
doctor.setMobilePhone(EncryptCreateUtil.encrypt(mobile)); doctor.setMobilePhone(AESUtil.encryptV0(mobile));
doctorMapper.updateByAcctId(doctor); doctorMapper.updateByAcctId(doctor);
} }
} }
......
...@@ -3,8 +3,8 @@ package com.pica.cloud.account.account.server.service.impl; ...@@ -3,8 +3,8 @@ package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.AccountInfoEntity; import com.pica.cloud.account.account.server.entity.AccountInfoEntity;
import com.pica.cloud.account.account.server.entity.Doctor; import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.entity.LogPWDModifyEntity; import com.pica.cloud.account.account.server.entity.LogPWDModifyEntity;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum; import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.exception.AccountException; import com.pica.cloud.account.account.server.exception.AccountException;
import com.pica.cloud.account.account.server.log.AccountLogEntityUtils; import com.pica.cloud.account.account.server.log.AccountLogEntityUtils;
import com.pica.cloud.account.account.server.log.AccountLogUtils; import com.pica.cloud.account.account.server.log.AccountLogUtils;
...@@ -12,7 +12,7 @@ import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; ...@@ -12,7 +12,7 @@ import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.DoctorMapper; import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.PasswordService; import com.pica.cloud.account.account.server.service.PasswordService;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil; import com.pica.cloud.account.account.server.util.AESUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -62,7 +62,7 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -62,7 +62,7 @@ public class PasswordServiceImpl implements PasswordService {
@Override @Override
@Transactional @Transactional
public void forgetPassword(BaseRequest request) { public void forgetPassword(BaseRequest request) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByMobile(EncryptCreateUtil.encrypt(request.getMobile())); AccountInfoEntity entity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(request.getMobile()));
if (entity != null) { if (entity != null) {
String password = request.getPassword(); String password = request.getPassword();
Integer accId = entity.getId(); Integer accId = entity.getId();
......
...@@ -8,7 +8,7 @@ import com.pica.cloud.account.account.server.log.AccountLogUtils; ...@@ -8,7 +8,7 @@ import com.pica.cloud.account.account.server.log.AccountLogUtils;
import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper; import com.pica.cloud.account.account.server.mapper.AccountInfoDetailMapper;
import com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper; import com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper;
import com.pica.cloud.account.account.server.service.PatientInfoService; import com.pica.cloud.account.account.server.service.PatientInfoService;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil; import com.pica.cloud.account.account.server.util.AESUtil;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -80,7 +80,7 @@ public class PatientInfoServerImpl implements PatientInfoService { ...@@ -80,7 +80,7 @@ public class PatientInfoServerImpl implements PatientInfoService {
accountInfoEntity.setName(entity.getName()); accountInfoEntity.setName(entity.getName());
accountInfoDetailMapper.insertSelective(accountInfoEntity); accountInfoDetailMapper.insertSelective(accountInfoEntity);
entity.setAcctId(accountInfoEntity.getId()); entity.setAcctId(accountInfoEntity.getId());
entity.setMobilePhone(EncryptCreateUtil.encrypt(entity.getMobilePhone())); entity.setMobilePhone(AESUtil.encryptV0(entity.getMobilePhone()));
entity.setModifyId(userId); entity.setModifyId(userId);
entity.setModifyTime(currentTime); entity.setModifyTime(currentTime);
accountPatientInfoMapper.insertSelective(entity); accountPatientInfoMapper.insertSelective(entity);
......
...@@ -17,13 +17,11 @@ import com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper; ...@@ -17,13 +17,11 @@ import com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper;
import com.pica.cloud.account.account.server.queue.QueueProducer; import com.pica.cloud.account.account.server.queue.QueueProducer;
import com.pica.cloud.account.account.server.req.BaseRequest; import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.service.RegisterService; import com.pica.cloud.account.account.server.service.RegisterService;
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.AccountUtils;
import com.pica.cloud.account.account.server.util.TokenUtils; import com.pica.cloud.account.account.server.util.TokenUtils;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
...@@ -43,10 +41,6 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -43,10 +41,6 @@ public class RegisterServiceImpl implements RegisterService {
@Autowired @Autowired
private AccountMapper accountMapper; private AccountMapper accountMapper;
@Autowired
@Qualifier("cacheMigrateClient")
private ICacheClient cacheClient;
@Autowired @Autowired
private AccountLogUtils picaLogUtils; private AccountLogUtils picaLogUtils;
...@@ -59,11 +53,18 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -59,11 +53,18 @@ public class RegisterServiceImpl implements RegisterService {
@Autowired @Autowired
private QueueProducer queueProducer; private QueueProducer queueProducer;
/**
* 1)注册功能:默认未完善信息;
* 2)注册成功后发送mq消息,让别的服务初始化数据;
* 3)记录登录日志;
*
* @param baseRequest 参数模型
* @return
*/
@Override @Override
public String register(BaseRequest baseRequest) { public String register(BaseRequest baseRequest) {
//对手机号进行加密处理
String mobile = baseRequest.getMobile(); String mobile = baseRequest.getMobile();
String mobileEncrypt = EncryptCreateUtil.encrypt(mobile); String mobileEncrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
Date currentTime = new Date(); Date currentTime = new Date();
...@@ -122,9 +123,7 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -122,9 +123,7 @@ public class RegisterServiceImpl implements RegisterService {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put(Constants.TOKEN, newToken); jsonObject.put(Constants.TOKEN, newToken);
jsonObject.put(Constants.USER_ID, userId); jsonObject.put(Constants.USER_ID, userId);
//注册功能:默认未完善信息
jsonObject.put(Constants.USER_ENTIRE_FLAG, 1); jsonObject.put(Constants.USER_ENTIRE_FLAG, 1);
//注册成功后发送mq消息,让别的服务初始化数据
ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos); DataOutputStream dos = new DataOutputStream(bos);
try { try {
...@@ -133,7 +132,6 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -133,7 +132,6 @@ public class RegisterServiceImpl implements RegisterService {
e.printStackTrace(); e.printStackTrace();
} }
queueProducer.send(bos.toByteArray()); queueProducer.send(bos.toByteArray());
//记录登录日志
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, baseRequest.getSourceType(), LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, baseRequest.getSourceType(),
AccountTypeEnum.LOGIN_REGISTER.getCode(), baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOGIN_REGISTER.getCode(), baseRequest.getLoginIp(), AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(),
AccountTypeEnum.LOG_TYPE_LOGIN.getCode()); AccountTypeEnum.LOG_TYPE_LOGIN.getCode());
...@@ -143,7 +141,4 @@ public class RegisterServiceImpl implements RegisterService { ...@@ -143,7 +141,4 @@ public class RegisterServiceImpl implements RegisterService {
throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER); throw new AccountException(AccountExceptionEnum.PICA_ALREADY_REGISTER);
} }
} }
} }
package com.pica.cloud.account.account.server.util; package com.pica.cloud.account.account.server.util;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import sun.misc.BASE64Decoder; import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder; import sun.misc.BASE64Encoder;
...@@ -37,6 +38,28 @@ public class AESUtil { ...@@ -37,6 +38,28 @@ public class AESUtil {
return key; return key;
} }
/**
* 旧的加密逻辑处理
*
* @param data 待加密的数据
* @return
*/
public static String encryptV0(String data) {
//EncryptUtils.encryptContent(mobilePhone, EncryptConstants.ENCRYPT_TYPE_MOBILE)
return EncryptCreateUtil.encrypt(data);
}
/**
* 旧的解密逻辑处理
*
* @param data 待解密的数据
* @return
*/
public static String decryptV0(String data) {
return EncryptCreateUtil.dencrypt(data);
}
/** /**
* 用来进行加密的操作 * 用来进行加密的操作
* *
......
...@@ -9,7 +9,6 @@ import com.pica.cloud.account.account.server.mapper.DoctorMapper; ...@@ -9,7 +9,6 @@ import com.pica.cloud.account.account.server.mapper.DoctorMapper;
import com.pica.cloud.foundation.entity.PicaException; import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode; import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.ICacheClient; import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import com.pica.cloud.foundation.utils.utils.ValidateUtils; import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -51,7 +50,7 @@ public class AccountUtils { ...@@ -51,7 +50,7 @@ public class AccountUtils {
//获取验证码redis key //获取验证码redis key
public static String getAuthCodeKey(String mobilePhone, String flag) { public static String getAuthCodeKey(String mobilePhone, String flag) {
return AUTH_CODE_PREFIX + flag + "-" + EncryptCreateUtil.encrypt(mobilePhone); return AUTH_CODE_PREFIX + flag + "-" + AESUtil.encryptV0(mobilePhone);
} }
//校验验证码 //校验验证码
...@@ -83,7 +82,7 @@ public class AccountUtils { ...@@ -83,7 +82,7 @@ public class AccountUtils {
} }
String authCodeKey = AccountUtils.getAuthCodeKey(mobile, flag); String authCodeKey = AccountUtils.getAuthCodeKey(mobile, flag);
//验证码3次校验测试不通过,直接删除 //验证码3次校验测试不通过,直接删除
String authCodeCount = AUTH_CODE_COUNT_PREFIX + flag + "-" + EncryptCreateUtil.encrypt(mobile); String authCodeCount = AUTH_CODE_COUNT_PREFIX + flag + "-" + AESUtil.encryptV0(mobile);
if (cacheClient.exists(authCodeCount) && Integer.parseInt(cacheClient.get(authCodeCount)) > 2) { if (cacheClient.exists(authCodeCount) && Integer.parseInt(cacheClient.get(authCodeCount)) > 2) {
cacheClient.del(authCodeKey); cacheClient.del(authCodeKey);
} }
...@@ -109,7 +108,7 @@ public class AccountUtils { ...@@ -109,7 +108,7 @@ public class AccountUtils {
* @return * @return
*/ */
public static <T> T getRequestEntity(String params, Class<T> zClass) throws Exception { public static <T> T getRequestEntity(String params, Class<T> zClass) throws Exception {
String json = EncryptCreateUtil.dencrypt(params); String json = AESUtil.decryptV0(params);
return JSONObject.parseObject(json, zClass); return JSONObject.parseObject(json, zClass);
} }
...@@ -162,7 +161,7 @@ public class AccountUtils { ...@@ -162,7 +161,7 @@ public class AccountUtils {
* @param mobile * @param mobile
*/ */
// public boolean checkRegisterMobile(String mobile) { // public boolean checkRegisterMobile(String mobile) {
// String encrypt = EncryptCreateUtil.encrypt(mobile); // String encrypt = AESUtil.encryptV0(mobile);
// AccountContact accountContact = accountContactServer.selectByMobile(encrypt); // AccountContact accountContact = accountContactServer.selectByMobile(encrypt);
// return (accountContact != null && accountContact.getAcctId() != null); // return (accountContact != null && accountContact.getAcctId() != null);
// } // }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册