修改密码
This commit is contained in:
parent
c76a0ba941
commit
2bc01c9128
|
@ -8,5 +8,5 @@ import java.util.List;
|
|||
public interface ExtUserMapper {
|
||||
|
||||
List<User> getUserList(@Param("userRequest") UserRequest request);
|
||||
int updatePassword(@Param("User")User record);
|
||||
int updatePassword(User record);
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import io.metersphere.commons.utils.Pager;
|
|||
import io.metersphere.controller.request.UserRequest;
|
||||
import io.metersphere.controller.request.member.AddMemberRequest;
|
||||
import io.metersphere.controller.request.member.QueryMemberRequest;
|
||||
import io.metersphere.controller.request.member.EditPassWordRequest;
|
||||
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
|
||||
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.dto.UserPassDTO;
|
||||
import io.metersphere.service.OrganizationService;
|
||||
import io.metersphere.service.UserService;
|
||||
import io.metersphere.service.WorkspaceService;
|
||||
|
@ -246,13 +246,13 @@ public class UserController {
|
|||
* 修改当前用户密码
|
||||
* */
|
||||
@PostMapping("/update/password")
|
||||
public int updateCurrentUserPassword(@RequestBody UserPassDTO UserPassDTO) {
|
||||
return userService.updatePassword(UserPassDTO);
|
||||
public int updateCurrentUserPassword(@RequestBody EditPassWordRequest request) {
|
||||
return userService.updateCurrentUserPassword(request);
|
||||
}
|
||||
/*管理员修改用户密码*/
|
||||
@PostMapping("/special/password")
|
||||
public int updateUserPassword(@RequestBody UserPassDTO UserPassDTO) {
|
||||
return userService.updateUserPassword(UserPassDTO);
|
||||
public int updateUserPassword(@RequestBody EditPassWordRequest request) {
|
||||
return userService.updateUserPassword(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package io.metersphere.controller.request.member;
|
||||
|
||||
import lombok.Data;
|
||||
@Data
|
||||
public class EditPassWordRequest {
|
||||
private String password;
|
||||
private String newpassword;
|
||||
private String id;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserPassDTO {
|
||||
private String password;
|
||||
private String newpassword;
|
||||
private String id;
|
||||
}
|
|
@ -8,11 +8,11 @@ import io.metersphere.commons.exception.MSException;
|
|||
import io.metersphere.commons.utils.CodingUtil;
|
||||
import io.metersphere.controller.request.UserRequest;
|
||||
import io.metersphere.controller.request.member.AddMemberRequest;
|
||||
import io.metersphere.controller.request.member.EditPassWordRequest;
|
||||
import io.metersphere.controller.request.member.QueryMemberRequest;
|
||||
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
|
||||
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
|
||||
import io.metersphere.dto.UserDTO;
|
||||
import io.metersphere.dto.UserPassDTO;
|
||||
import io.metersphere.i18n.Translator;
|
||||
import io.metersphere.user.SessionUser;
|
||||
import io.metersphere.user.SessionUtils;
|
||||
|
@ -259,12 +259,12 @@ public class UserService {
|
|||
}
|
||||
|
||||
/*修改当前用户用户密码*/
|
||||
private User getUserPassDTO(UserPassDTO UserPassDTO) {
|
||||
private User updateCurrentUserPwd(EditPassWordRequest request) {
|
||||
if (SessionUtils.getUser() != null) {
|
||||
User user = userMapper.selectByPrimaryKey(SessionUtils.getUser().getId());
|
||||
String pwd = user.getPassword();
|
||||
String prepwd = CodingUtil.md5(UserPassDTO.getPassword(),"utf-8");
|
||||
String newped = UserPassDTO.getNewpassword();
|
||||
String prepwd = CodingUtil.md5(request.getPassword(),"utf-8");
|
||||
String newped = request.getNewpassword();
|
||||
if (StringUtils.isNotBlank(prepwd)) {
|
||||
if (prepwd.trim().equals(pwd.trim())) {
|
||||
user.setPassword(CodingUtil.md5(newped));
|
||||
|
@ -277,22 +277,21 @@ public class UserService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public int updatePassword(UserPassDTO UserPassDTO) {
|
||||
User user = getUserPassDTO(UserPassDTO);
|
||||
return userMapper.updatePassword(user);
|
||||
public int updateCurrentUserPassword(EditPassWordRequest request) {
|
||||
User user = updateCurrentUserPwd(request);
|
||||
return extUserMapper.updatePassword(user);
|
||||
}
|
||||
/*管理员修改用户密码*/
|
||||
private User getUserDTO(UserPassDTO UserPassDTO){
|
||||
User user= userMapper.selectByPrimaryKey(UserPassDTO.getId());
|
||||
String newped = UserPassDTO.getNewpassword();
|
||||
private User updateUserPwd(EditPassWordRequest request){
|
||||
User user= userMapper.selectByPrimaryKey(request.getId());
|
||||
String newped = request.getNewpassword();
|
||||
user.setPassword(CodingUtil.md5(newped));
|
||||
user.setUpdateTime(System.currentTimeMillis());
|
||||
return user;
|
||||
}
|
||||
public int updateUserPassword(UserPassDTO UserPassDTO){
|
||||
User user=getUserDTO(UserPassDTO);
|
||||
int i=userMapper.updatePassword(user);
|
||||
return i;
|
||||
public int updateUserPassword(EditPassWordRequest request){
|
||||
User user=updateUserPwd(request);
|
||||
return extUserMapper.updatePassword(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue