diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java index ed2ad65f..41e4403f 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java @@ -36,7 +36,15 @@ public class UserLoginController { return "Hello"; } + @PostMapping("/verifyMobile") + @ApiOperation(value = "验证手机号及验证码") + public ResponseResult verifyMobile(@RequestBody @Valid UserLoginRequest user){ + UserLoginRequest result = userLoginService.verifyMobile(user); + return ResponseResult.SUCCESS(result); + } + @PostMapping("/getBackPwd") + @ApiOperation(value = "重置密码") public ResponseResult getBackPwd(@RequestBody @Valid UserLoginRequest user){ boolean result = userLoginService.getBackPwd(user); return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL(); diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java index 583a4618..47481c74 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java @@ -12,6 +12,7 @@ import com.daqing.framework.model.response.ResponseResult; */ public interface UserLoginService extends IService { Boolean getBackPwd(UserLoginRequest user); + UserLoginRequest verifyMobile(UserLoginRequest user); //登录 ResponseResult login(LoginRequest loginRequest); 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 824f8f49..c08cac85 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 @@ -43,10 +43,10 @@ public class UserLoginServiceImpl extends ServiceImpl }*/ /** - * 忘记密码 + * 验证手机号及验证码 */ @Override - public Boolean getBackPwd(UserLoginRequest user){ + public UserLoginRequest verifyMobile(UserLoginRequest user){ //判断重置密码参数是否为空 if(StringUtils.isEmpty(user.getPhoneAccount())){ ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY); @@ -54,9 +54,7 @@ public class UserLoginServiceImpl extends ServiceImpl if(StringUtils.isEmpty(user.getVerifyCode())){ ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL); } - if(StringUtils.isEmpty(user.getNewPwd())){ - ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY); - } + //校验手机账号是否存在 /* int count = this.count(new QueryWrapper() .eq("phone_account", user.getPhoneAccount()));*/ @@ -65,13 +63,33 @@ public class UserLoginServiceImpl extends ServiceImpl if (count == 0) { ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EXIST); } - //根据手机号查询相关信息 - UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount()); //判断验证码是否匹配 String verify = "123456"; if(!verify.equals(user.getVerifyCode())){ ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL); } + return user; + } + + + /** + * 重置密码 + */ + @Override + public Boolean getBackPwd(UserLoginRequest user){ + //判断重置密码参数是否为空 + if(StringUtils.isEmpty(user.getNewPwd())){ + ExceptionCast.cast(HrmsCode.NEW_PASSWORD_NOT_EMPTY); + } + if(StringUtils.isEmpty(user.getConfirmPwd())){ + ExceptionCast.cast(HrmsCode.CONFIRM_PWD_NOT_EMPTY); + } + if(!user.getConfirmPwd().equals(user.getNewPwd())){ + ExceptionCast.cast(HrmsCode.TWICE_PWD_DIFFERENT); + } + + //根据手机号查询相关信息 + UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount()); String newMD5 = Md5Util.md5(user.getNewPwd()+userEntity.getId()); //根据手机号码修改密码 diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/UserLoginRequest.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/UserLoginRequest.java index 13b39d2c..c6428064 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/UserLoginRequest.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/UserLoginRequest.java @@ -30,4 +30,8 @@ public class UserLoginRequest implements Serializable { */ @Pattern(regexp = "^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$",message = "密码格式不正确!") private String newPwd; + /** + * 确认密码 + */ + private String confirmPwd; } diff --git a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java index 52fcc512..528a08de 100644 --- a/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java +++ b/dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java @@ -27,6 +27,8 @@ public enum HrmsCode implements ResultCode { NEW_PASSWORD_ILLEGAL(false,33004,"新密码格式不正确!"), VERIFY_CODE_ILLEGAL(false,33005,"验证码不匹配!"), PHNOE_ACCOUNT_NOT_EXIST(false,33006,"手机号码不存在!"), + CONFIRM_PWD_NOT_EMPTY(false,33007,"确认密码不能为空!"), + TWICE_PWD_DIFFERENT(false,33008,"两次输入密码不一致!"), EMP_POSITION_EXSIT(false, 22006, "该职位下已关联员工!"); diff --git a/dq-govern-gateway/src/main/resources/jwt.properties b/dq-govern-gateway/src/main/resources/jwt.properties index d8152474..441fb9cd 100644 --- a/dq-govern-gateway/src/main/resources/jwt.properties +++ b/dq-govern-gateway/src/main/resources/jwt.properties @@ -1 +1 @@ -jwt.ignoreUrlList=/apiHrmsAuth/hrms/auth/userlogin/getBackPwd,/apiHrmsAuth/hrms/auth/userlogin/login +jwt.ignoreUrlList=/apiHrmsAuth/hrms/auth/userlogin/getBackPwd,/apiHrmsAuth/hrms/auth/userlogin/login,/apiHrmsAuth/hrms/auth/userlogin/verifyMobile