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

20191025 完善修改密码接口

上级 51c3e31b
流水线 #16312 已失败 于阶段
in 0 second
...@@ -44,15 +44,15 @@ public class PasswordController extends AccountBaseController { ...@@ -44,15 +44,15 @@ public class PasswordController extends AccountBaseController {
@PostMapping(value = "/modify") @PostMapping(value = "/modify")
public PicaResponse modifyPassword(@RequestBody EncryptEntity entity) throws Exception { public PicaResponse modifyPassword(@RequestBody EncryptEntity entity) throws Exception {
PicaUser picaUser = super.getPicaUser(); PicaUser picaUser = super.getPicaUser();
String mobile = picaUser.getMobile(); String mobile = AESUtil.encryptV0(picaUser.getMobile());
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(AESUtil.encryptV0(mobile)); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobile);
if (accountInfoEntity != null) { if (accountInfoEntity != null) {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class); BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
String oldPwd = request.getOldPwd(); String oldPwd = request.getOldPwd();
String password = request.getPassword(); String password = request.getPassword();
if (!StringUtils.isEmpty(password) && !StringUtils.isEmpty(oldPwd)) { if (!StringUtils.isEmpty(password) && !StringUtils.isEmpty(oldPwd)) {
if (!password.equals(oldPwd)) { if (!password.equals(oldPwd)) {
passwordService.modifyPassword(accountInfoEntity.getId(), oldPwd, password); passwordService.modifyPassword(mobile, oldPwd, password);
return PicaResponse.toResponse(); return PicaResponse.toResponse();
} else { } else {
throw new AccountException(AccountExceptionEnum.PICA_PASSWORD_EQUAL); throw new AccountException(AccountExceptionEnum.PICA_PASSWORD_EQUAL);
......
...@@ -48,6 +48,8 @@ public interface DoctorMapper { ...@@ -48,6 +48,8 @@ public interface DoctorMapper {
*/ */
void updateByAcctId(Doctor doctor); void updateByAcctId(Doctor doctor);
void updateByMobile(Doctor doctor);
int deleteByPrimaryKey(Integer id); int deleteByPrimaryKey(Integer id);
int insert(Doctor record); int insert(Doctor record);
...@@ -75,6 +77,8 @@ public interface DoctorMapper { ...@@ -75,6 +77,8 @@ public interface DoctorMapper {
void updateDeleteByPrimaryKey(Integer id); void updateDeleteByPrimaryKey(Integer id);
/** /**
* 通过手机号获取用户id * 通过手机号获取用户id
* @param mobile * @param mobile
......
...@@ -7,11 +7,11 @@ public interface PasswordService { ...@@ -7,11 +7,11 @@ public interface PasswordService {
/** /**
* 修改密码 * 修改密码
* *
* @param acctId 账户id * @param mobile 账户id
* @param oldPwd 旧密码 * @param oldPwd 旧密码
* @param pwd 新密码 * @param pwd 新密码
*/ */
void modifyPassword(Integer acctId, String oldPwd, String pwd); void modifyPassword(String mobile, String oldPwd, String pwd);
/** /**
* 忘记密码 * 忘记密码
......
...@@ -37,19 +37,19 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -37,19 +37,19 @@ public class PasswordServiceImpl implements PasswordService {
@Override @Override
@Transactional @Transactional
public void modifyPassword(Integer acctId, String oldPwd, String pwd) { public void modifyPassword(String mobile, String oldPwd, String pwd) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByPrimaryKey(acctId); AccountInfoEntity entity = accountInfoDetailMapper.selectByMobile(mobile);
if (entity != null) { if (entity != null) {
if (entity.getPassword().equals(oldPwd)) { if (entity.getPassword().equals(oldPwd)) {
Date currentTime = new Date(); Date currentTime = new Date();
AccountInfoEntity accountInfoEntity = new AccountInfoEntity(); AccountInfoEntity accountInfoEntity = new AccountInfoEntity();
accountInfoEntity.setId(acctId); accountInfoEntity.setId(entity.getId());
accountInfoEntity.setModifiedId(acctId); accountInfoEntity.setModifiedId(entity.getId());
accountInfoEntity.setModifiedTime(currentTime); accountInfoEntity.setModifiedTime(currentTime);
accountInfoEntity.setPassword(pwd); accountInfoEntity.setPassword(pwd);
accountInfoDetailMapper.updatePasswordByPrimaryKey(accountInfoEntity); accountInfoDetailMapper.updatePasswordByPrimaryKey(accountInfoEntity);
if (doubleWritingMode) { if (doubleWritingMode) {
processDoubleWrite(acctId, pwd); processDoubleWrite(mobile, pwd);
} }
//密码修改日志 //密码修改日志
LogPWDModifyEntity logPWDModifyEntity = AccountLogEntityUtils.getLogPWDModifyEntity(acctId, entity.getMobilePhone(), LogPWDModifyEntity logPWDModifyEntity = AccountLogEntityUtils.getLogPWDModifyEntity(acctId, entity.getMobilePhone(),
...@@ -78,7 +78,7 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -78,7 +78,7 @@ public class PasswordServiceImpl implements PasswordService {
accountInfoEntity.setPassword(password); accountInfoEntity.setPassword(password);
accountInfoDetailMapper.updatePasswordByPrimaryKey(accountInfoEntity); accountInfoDetailMapper.updatePasswordByPrimaryKey(accountInfoEntity);
if (doubleWritingMode) { if (doubleWritingMode) {
processDoubleWrite(accId, password); processDoubleWrite(AESUtil.encryptV0(request.getMobile()), password);
} }
//密码修改日志 //密码修改日志
LogPWDModifyEntity logPWDModifyEntity = AccountLogEntityUtils.getLogPWDModifyEntity(accId, entity.getMobilePhone(), LogPWDModifyEntity logPWDModifyEntity = AccountLogEntityUtils.getLogPWDModifyEntity(accId, entity.getMobilePhone(),
...@@ -93,16 +93,16 @@ public class PasswordServiceImpl implements PasswordService { ...@@ -93,16 +93,16 @@ public class PasswordServiceImpl implements PasswordService {
/** /**
* 双写模式,把密码存储到p_doctor表 * 双写模式,把密码存储到p_doctor表
* *
* @param accId * @param mobile
* @param password * @param password
*/ */
private void processDoubleWrite(Integer accId, String password) { private void processDoubleWrite(String mobile, String password) {
Date currentTime = new Date(); Date currentTime = new Date();
Doctor doctor = new Doctor(); Doctor doctor = new Doctor();
doctor.setPassword(password); doctor.setPassword(password);
doctor.setAcctId(accId); doctor.setMobilePhone(mobile);
doctor.setModifyTime(currentTime); doctor.setModifyTime(currentTime);
doctor.setModifyId(accId); doctor.setModifyId(0);
doctorMapper.updateByAcctId(doctor); doctorMapper.updateByMobile(doctor);
} }
} }
...@@ -157,7 +157,7 @@ public class AESUtil { ...@@ -157,7 +157,7 @@ public class AESUtil {
*/ */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
String KEY="zJJ$c5md3$yuuhWW"; String KEY="zJJ$c5md3$yuuhWW";
String content = "12322222222"; String content = "15607241351";
System.out.println("加密前:" + content); System.out.println("加密前:" + content);
System.out.println("加密密钥和解密密钥:" + KEY); System.out.println("加密密钥和解密密钥:" + KEY);
String encrypt = aesEncrypt(content, KEY); String encrypt = aesEncrypt(content, KEY);
......
...@@ -143,6 +143,12 @@ ...@@ -143,6 +143,12 @@
<!--limit 0,1--> <!--limit 0,1-->
<!--</select>--> <!--</select>-->
<update id="updateByMobile" parameterType="com.pica.cloud.account.account.server.entity.Doctor">
update p_doctor set password=#{password},modify_time=now(), modify_id=#{id} where mobile_phone=#{mobilePhone} and delete_flag=1 limit 1
</update>
<!--通过账户id更新用户信息--> <!--通过账户id更新用户信息-->
<update id="updateByAcctId" parameterType="com.pica.cloud.account.account.server.entity.Doctor"> <update id="updateByAcctId" parameterType="com.pica.cloud.account.account.server.entity.Doctor">
update p_doctor update p_doctor
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册