From 3a1e4f6d392eaacf7588917bd47dd7f4c724c7f3 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Mon, 28 Sep 2020 09:50:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=BE=E5=9B=9E=E5=AF=86=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../daqing/financial/hrauth/dao/UserLoginDao.java | 1 + .../hrauth/service/impl/UserLoginServiceImpl.java | 14 +++++++------- .../resources/mapper/hrmsauth/UserLoginMapper.xml | 3 +++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java index 40f41009..439b9691 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java @@ -18,4 +18,5 @@ public interface UserLoginDao extends BaseMapper { int updatePasswordByPhoneAccount(@Param("phoneAccount") String phoneAccount, @Param("password") String password); UserEntity login(LoginRequest loginRequest); + UserEntity selectByPhoneAccount(String phoneAccount); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java index 7d5332ed..50d922d3 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java @@ -14,12 +14,10 @@ import com.daqing.framework.model.response.CommonCode; import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.util.Md5Util; import org.apache.commons.lang3.StringUtils; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * @auther River @@ -49,7 +47,7 @@ public class UserLoginServiceImpl extends ServiceImpl * 忘记密码 */ @Override - public Boolean getBackPwd(UserLoginRequest user){ + public Boolean getBackPwd(@Validated UserLoginRequest user){ //判断重置密码参数是否为空 if(StringUtils.isEmpty(user.getPhoneAccount())){ ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY); @@ -68,18 +66,20 @@ public class UserLoginServiceImpl extends ServiceImpl if (count == 0) { ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY); } + //根据手机号查询相关信息 + UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount()); //判断验证码是否匹配 String verify = "123456"; if(!verify.equals(user.getVerifyCode())){ ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL); } //密码格式校验 - Pattern pattern = Pattern.compile("^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$"); +/* Pattern pattern = Pattern.compile("^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$"); Matcher match = pattern.matcher(user.getNewPwd()); if(!match.matches()){ ExceptionCast.cast(HrmsCode.NEW_PASSWORD_ILLEGAL); - } - String newMD5 = new BCryptPasswordEncoder().encode(user.getNewPwd()); + }*/ + String newMD5 = Md5Util.md5(user.getNewPwd()+userEntity.getId()); //根据手机号码修改密码 int i = userLoginDao.updatePasswordByPhoneAccount(user.getPhoneAccount(),newMD5); return i > 0; diff --git a/dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/UserLoginMapper.xml b/dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/UserLoginMapper.xml index 726e4d93..9a66957d 100644 --- a/dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/UserLoginMapper.xml +++ b/dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/UserLoginMapper.xml @@ -34,5 +34,8 @@ + \ No newline at end of file