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

20190911 双写模式把信息写入doctor表

上级 b06baf81
流水线 #14366 已失败 于阶段
in 0 second
......@@ -40,6 +40,12 @@ public interface DoctorMapper {
int updateByPrimaryKeySelective(Doctor record);
/**
* 通过账户id更新用户信息
* @param doctor
*/
void updateByAcctId(Doctor doctor);
int deleteByPrimaryKey(Integer id);
int insert(Doctor record);
......@@ -47,6 +53,4 @@ public interface DoctorMapper {
int insertSelective(Doctor record);
int updateByPrimaryKey(Doctor record);
}
\ No newline at end of file
......@@ -117,7 +117,6 @@ public class LoginServiceImpl implements LoginService {
}
}
@Override
public String loginAndRegister(BaseRequest baseRequest) {
String mobile = baseRequest.getMobile();
......@@ -237,7 +236,6 @@ public class LoginServiceImpl implements LoginService {
processAccountUnion(request.getAccId(), unionId);
}
private void processAccountUnion(Integer acctId, String unionId) {
AccountUnionEntity accountUnionEntity = new AccountUnionEntity();
accountUnionEntity.setAcctId(acctId.longValue());
......
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.Doctor;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
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.DoctorMapper;
import com.pica.cloud.account.account.server.service.ModifyMobileService;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
......@@ -18,6 +22,12 @@ public class ModifyMobileServiceImpl implements ModifyMobileService {
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired
private DoctorMapper doctorMapper;
@Value("${doubleWritingMode}")
private boolean doubleWritingMode;
@Override
public void modify(Integer acctId, String mobile) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByPrimaryKey(acctId);
......@@ -31,5 +41,15 @@ public class ModifyMobileServiceImpl implements ModifyMobileService {
accountInfoEntity.setModifiedTime(new Date());
accountInfoEntity.setMobilePhone(EncryptCreateUtil.encrypt(mobile));
accountInfoDetailMapper.updateMobileByPrimaryKey(accountInfoEntity);
if (doubleWritingMode) {
//更新p_doctor表中用户的手机号
Date currentTime = new Date();
Doctor doctor = new Doctor();
doctor.setAcctId(acctId);
doctor.setModifyTime(currentTime);
doctor.setModifyId(acctId);
doctor.setMobilePhone(EncryptCreateUtil.encrypt(mobile));
doctorMapper.updateByAcctId(doctor);
}
}
}
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.Doctor;
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;
......@@ -8,10 +9,12 @@ 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.AccountLogUtils;
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.req.BaseRequest;
import com.pica.cloud.account.account.server.service.PasswordService;
import com.pica.cloud.foundation.utils.utils.EncryptCreateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
......@@ -22,19 +25,29 @@ public class PasswordServiceImpl implements PasswordService {
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired
private DoctorMapper doctorMapper;
@Autowired
private AccountLogUtils picaLogUtils;
@Value("${doubleWritingMode}")
private boolean doubleWritingMode;
@Override
public void modifyPassword(Integer acctId, String oldPwd, String pwd) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByPrimaryKey(acctId);
if (entity.getPassword().equals(oldPwd)) {
Date currentTime = new Date();
AccountInfoEntity accountInfoEntity = new AccountInfoEntity();
accountInfoEntity.setId(acctId);
accountInfoEntity.setModifiedId(acctId);
accountInfoEntity.setModifiedTime(new Date());
accountInfoEntity.setModifiedTime(currentTime);
accountInfoEntity.setPassword(pwd);
accountInfoDetailMapper.updatePasswordByPrimaryKey(accountInfoEntity);
if (doubleWritingMode) {
processDoubleWrite(acctId, pwd);
}
//密码修改日志
LogPWDModifyEntity logPWDModifyEntity = AccountLogEntityUtils.getLogPWDModifyEntity(acctId, entity.getMobilePhone(),
oldPwd, pwd, AccountTypeEnum.LOG_TYPE_PASSWORD.getCode());
......@@ -48,13 +61,18 @@ public class PasswordServiceImpl implements PasswordService {
public void forgetPassword(BaseRequest request) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByMobile(EncryptCreateUtil.encrypt(request.getMobile()));
if (entity != null) {
String password = request.getPassword();
Integer accId = entity.getId();
Date currentTime = new Date();
AccountInfoEntity accountInfoEntity = new AccountInfoEntity();
accountInfoEntity.setId(accId);
accountInfoEntity.setModifiedId(accId);
accountInfoEntity.setModifiedTime(new Date());
accountInfoEntity.setPassword(request.getPassword());
accountInfoEntity.setModifiedTime(currentTime);
accountInfoEntity.setPassword(password);
accountInfoDetailMapper.updatePasswordByPrimaryKey(accountInfoEntity);
if (doubleWritingMode) {
processDoubleWrite(accId, password);
}
//密码修改日志
LogPWDModifyEntity logPWDModifyEntity = AccountLogEntityUtils.getLogPWDModifyEntity(accId, entity.getMobilePhone(),
"", request.getPassword(), AccountTypeEnum.LOG_TYPE_PASSWORD.getCode());
......@@ -64,4 +82,20 @@ public class PasswordServiceImpl implements PasswordService {
throw new AccountException(AccountExceptionEnum.PICA_NOT_REGISTER);
}
}
/**
* 双写模式,把密码存储到p_doctor表
*
* @param accId
* @param password
*/
private void processDoubleWrite(Integer accId, String password) {
Date currentTime = new Date();
Doctor doctor = new Doctor();
doctor.setPassword(password);
doctor.setAcctId(accId);
doctor.setModifyTime(currentTime);
doctor.setModifyId(accId);
doctorMapper.updateByAcctId(doctor);
}
}
......@@ -14,6 +14,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.AccountMapper;
import com.pica.cloud.account.account.server.mapper.AccountPatientInfoMapper;
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.service.RegisterService;
import com.pica.cloud.account.account.server.util.AccountUtils;
......@@ -24,6 +25,7 @@ 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.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
......@@ -62,13 +64,13 @@ public class RegisterServiceImpl implements RegisterService {
Date currentTime = new Date();
int productType = baseRequest.getProductType();
int sourceType = baseRequest.getSourceType();
String password = baseRequest.getPassword();
AccountInfoEntity accountInfo = new AccountInfoEntity();
accountInfo.setMobilePhone(EncryptCreateUtil.encrypt(baseRequest.getMobile()));
if (StringUtils.isNotEmpty(baseRequest.getPassword())) {
accountInfo.setPassword(baseRequest.getPassword());
} else {
accountInfo.setPassword("");
if (StringUtils.isEmpty(password)) {
password = "";
}
accountInfo.setPassword(password);
accountInfo.setCreatedTime(currentTime);
accountInfo.setCreatedId(0);
accountInfo.setModifiedId(0);
......@@ -93,10 +95,11 @@ public class RegisterServiceImpl implements RegisterService {
} else {
Account account = new Account();
account.setAcctId(acctId);
account.setMobilePhone(EncryptCreateUtil.encrypt(account.getMobilePhone())); //手机号加密
account.setMobilePhone(EncryptCreateUtil.encrypt(account.getMobilePhone()));
account.setDeleteFlag(1);
account.setCreatId(0L);
account.setModifyId(0L);
account.setPassword(password);
account.setCreatTime(currentTime);
account.setModifyTime(currentTime);
account.setFirstLoginTime(currentTime);
......
......@@ -41,4 +41,8 @@ weChatAppID=wx5103ed453ef2dbe8
weChatAppSecret=6faa9bef3302786c08b2baf278613f38
weChatURL=https://api.weixin.qq.com/sns/userinfo?
doubleWritingMode=true
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册