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

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

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