修改平台超管员密码

master
shijie 4 years ago
parent b9537077ef
commit 1f26d2950d
  1. 3
      dq-financial-api/src/main/java/com/daqing/financial/hrauth/UserLoginControllerApi.java
  2. 8
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java
  3. 3
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java
  4. 52
      dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java
  5. 2
      dq-financial-hrms-auth/src/main/resources/mapper/hrmsauth/UserLoginMapper.xml
  6. 40
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/UpdatePwdRequest.java
  7. 5
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/request/UserLoginRequest.java
  8. 2
      dq-framework-model/src/main/java/com/daqing/framework/domain/hrms/response/HrmsCode.java

@ -1,6 +1,7 @@
package com.daqing.financial.hrauth;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UpdatePwdRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
@ -26,5 +27,7 @@ public interface UserLoginControllerApi {
@ApiOperation(value = "登录")
ResponseResult login(LoginRequest loginRequest);
@ApiOperation(value = "修改超管员密码")
ResponseResult updatePwd(UpdatePwdRequest user);
}

@ -3,6 +3,7 @@ package com.daqing.financial.hrauth.controller;
import com.daqing.financial.hrauth.UserLoginControllerApi;
import com.daqing.financial.hrauth.service.UserLoginService;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UpdatePwdRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult;
import io.swagger.annotations.Api;
@ -68,4 +69,11 @@ public class UserLoginController implements UserLoginControllerApi {
loginRequest.setPhone(phone);*/
return userLoginService.login(loginRequest);
}
@PostMapping("/updatePwd")
@ApiOperation(value = "修改平台超管员密码")
public ResponseResult updatePwd(@RequestBody @Valid UpdatePwdRequest user){
boolean result = userLoginService.updatePwd(user);
return result ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
}

@ -3,6 +3,7 @@ package com.daqing.financial.hrauth.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UpdatePwdRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.model.response.ResponseResult;
@ -16,4 +17,6 @@ public interface UserLoginService extends IService<UserEntity> {
//登录
ResponseResult login(LoginRequest loginRequest);
Boolean updatePwd(UpdatePwdRequest user);
}

@ -10,6 +10,7 @@ import com.daqing.framework.domain.hrms.LoginLog;
import com.daqing.framework.domain.hrms.Token;
import com.daqing.framework.domain.hrms.UserEntity;
import com.daqing.framework.domain.hrms.request.LoginRequest;
import com.daqing.framework.domain.hrms.request.UpdatePwdRequest;
import com.daqing.framework.domain.hrms.request.UserLoginRequest;
import com.daqing.framework.domain.hrms.response.HrmsCode;
import com.daqing.framework.domain.hrms.response.LoginResponse;
@ -62,14 +63,6 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
*/
@Override
public UserLoginRequest verifyMobile(UserLoginRequest user){
//判断重置密码参数是否为空
if(StringUtils.isEmpty(user.getPhoneAccount())){
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EMPTY);
}
if(StringUtils.isEmpty(user.getVerifyCode())){
ExceptionCast.cast(HrmsCode.VERIFY_CODE_ILLEGAL);
}
//校验手机账号是否存在
/* int count = this.count(new QueryWrapper<UserEntity>()
.eq("phone_account", user.getPhoneAccount()));*/
@ -92,13 +85,6 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
*/
@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);
}
@ -186,4 +172,40 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginDao, UserEntity>
return ResponseResult.SUCCESS(loginResponse);
}
/**
* 修改平台超管员密码
*/
@Override
public Boolean updatePwd(UpdatePwdRequest user){
if(!user.getConfirmPwd().equals(user.getNewPwd())){
ExceptionCast.cast(HrmsCode.TWICE_PWD_DIFFERENT);
}
//根据手机号查询相关信息
UserEntity userEntity = baseMapper.selectByPhoneAccount(user.getPhoneAccount());
if(userEntity == null){
ExceptionCast.cast(HrmsCode.PHNOE_ACCOUNT_NOT_EXIST);
}
//新密码不能与账号相同
if(user.getNewPwd().equals(userEntity.getAccount())){
ExceptionCast.cast(HrmsCode.NEW_PASSWORD_DIFFERENT);
}
//检测当前密码是否输入正确
if(!Md5Util.md5(user.getPassword()+userEntity.getId()).equals(userEntity.getPassword())){
ExceptionCast.cast(HrmsCode.PASSWORD_ERROR);
}
//新密码不能与当前密码保持一致
if(Md5Util.md5(user.getNewPwd()+userEntity.getId()).equals(userEntity.getPassword())){
ExceptionCast.cast(HrmsCode.NEWPWD_PASSWORD_SAME);
}
String newMD5 = Md5Util.md5(user.getNewPwd()+userEntity.getId());
//根据手机号码修改密码
int i = userLoginDao.updatePasswordByPhoneAccount(user.getPhoneAccount(),newMD5);
return i > 0;
}
}

@ -35,7 +35,7 @@
</select>
<select id="selectByPhoneAccount" resultType="com.daqing.framework.domain.hrms.UserEntity">
SELECT id,account FROM hrms_user WHERE phone_account = #{phoneAccount}
SELECT id,account,password FROM hrms_user WHERE phone_account = #{phoneAccount}
</select>
</mapper>

@ -0,0 +1,40 @@
package com.daqing.framework.domain.hrms.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
* 修改平台超管员密码请求体对象
*
* @author gongsj
* @email gongsj@gmail.com
* @date 2020-09-07 17:12:14
*/
@Data
public class UpdatePwdRequest implements Serializable {
/**
* 手机账号
*/
@Pattern(regexp = "^1(3([0-35-9]\\d|4[1-8])|4[14-9]\\d|5([0125689]\\d|7[1-79])|66\\d|7[2-35-8]\\d|8\\d{2}|9[13589]\\d)\\d{7}$",message = "手机号格式不正确!")
private String phoneAccount;
/**
* 新密码
*/
@Pattern(regexp = "^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$",message = "密码格式不正确!")
private String newPwd;
/**
* 确认密码
*/
private String confirmPwd;
/**
* 原密码
*/
@NotBlank(message = "当前密码不能为空!")
private String password;
}

@ -2,6 +2,7 @@ package com.daqing.framework.domain.hrms.request;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
@ -18,20 +19,24 @@ public class UserLoginRequest implements Serializable {
/**
* 手机账号
*/
@NotBlank(message = "手机号码不能为空!")
@Pattern(regexp = "^1(3([0-35-9]\\d|4[1-8])|4[14-9]\\d|5([0125689]\\d|7[1-79])|66\\d|7[2-35-8]\\d|8\\d{2}|9[13589]\\d)\\d{7}$",message = "手机号格式不正确!")
private String phoneAccount;
/**
* 验证码
*/
@NotBlank(message = "验证码不能为空!")
private String verifyCode;
/**
* 新密码
*/
@Pattern(regexp = "^(?=.*[0-9].*)(?=.*[A-Z].*)(?=.*[a-z].*).{6,20}$",message = "密码格式不正确!")
@NotBlank(message = "新密码不能为空!")
private String newPwd;
/**
* 确认密码
*/
@NotBlank(message = "确认密码不能为空!")
private String confirmPwd;
}

@ -30,6 +30,8 @@ public enum HrmsCode implements ResultCode {
CONFIRM_PWD_NOT_EMPTY(false,33007,"确认密码不能为空!"),
TWICE_PWD_DIFFERENT(false,33008,"两次输入密码不一致!"),
NEW_PASSWORD_DIFFERENT(false,33008,"输入的新密码不能与账号相同!"),
PASSWORD_ERROR(false,33009,"当前密码输入不正确!"),
NEWPWD_PASSWORD_SAME(false,33010,"新密码不能与当前密码一致!"),
EMP_POSITION_EXSIT(false, 22006, "该职位下已关联员工!");

Loading…
Cancel
Save