最近作完工程總結接口java
接口定義以下sql
思路以下app
1.修改密碼code
sql以下,看看就懂接口
update t_user set PASSWORD = #{newPassword} where t_user.PASSWORD = #{oldPassword} AND (PHONE_NUM = #{loginInfo} or EMAIL = #{loginInfo})
2.找回密碼it
找回密碼便是重置密碼,用戶短信驗證成功後,只須要將新密碼設置進來便可,sql以下io
update t_user set t_user.PASSWORD = #{newPassword} where PHONE_NUM = #{loginInfo} or EMAIL = #{loginInfo}
3.實現層以下class
/** * 用戶密碼修改 * * @param loginInfo * 用戶手機號碼或郵箱 * @param newPassword * 新密碼 * @param oldPassword * 舊密碼 * @param optType * 密碼修改模式(0, 修改密碼;1:找回密碼) * @return 成功/失敗 * @throws Exception */ public ResultObject updatePassword(String loginInfo, String newPassword, String oldPassword, Integer optType){ ResultObject ro = new ResultObject(); //判斷標誌位 boolean needBreak = false; //修改密碼 switch (optType) { case 0: //帳號、新密碼、舊密碼不能爲空 if ( StringUtils.isEmpty(loginInfo)|| StringUtils.isEmpty(newPassword) || StringUtils.isEmpty(oldPassword)){ ro.setResultCode(ResultCode.FAILED); ro.setResultMsg(ResultMsg.MSG_FAILED); needBreak = true; }else if (StringUtils.equals(newPassword, oldPassword)) { //新舊密碼不能相同 ro.setResultCode(ResultCode.FAILED); ro.setResultMsg(ResultMsg.MSG_FAILED); needBreak = true; } if (!needBreak) { //修改密碼 int success = customerInfoMapper.updPassword(loginInfo, newPassword, oldPassword); if (success == 1) { //成功 ro.setResultCode(ResultCode.SUCCESS); ro.setResultMsg(ResultMsg.MSG_SUCCESS); }else { ro.setResultCode(ResultCode.FAILED); ro.setResultMsg(ResultMsg.MSG_MODIFY_PASSWORD_FAILED); } } break; case 1: //帳號、重置密碼不能爲空 if ( StringUtils.isEmpty(loginInfo)|| StringUtils.isEmpty(newPassword)){ ro.setResultCode(ResultCode.FAILED); ro.setResultMsg(ResultMsg.MSG_FAILED); needBreak = true; } if (!needBreak) { int success = customerInfoMapper.setPassword(loginInfo, newPassword); if (success == 1) { //成功 ro.setResultCode(ResultCode.SUCCESS); ro.setResultMsg(ResultMsg.MSG_SUCCESS); }else { ro.setResultCode(ResultCode.FAILED); ro.setResultMsg(ResultMsg.MSG_SET_PASSWORD_FAILED); } } default: ro.setResultCode(ResultCode.FAILED); ro.setResultMsg(ResultMsg.MSG_FAILED); break; } return ro; }