From 92704173dd55a576581636bc373991ba9bcab824 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Mon, 11 May 2020 15:47:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/base/mapper/ext/ExtUserMapper.xml | 1 + .../io/metersphere/controller/UserController.java | 8 +++++--- .../java/io/metersphere/service/UserService.java | 13 ++++++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml index edf0931e8f..afa432e7d2 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml @@ -32,6 +32,7 @@ + update user diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index e15cd417ed..2d89ae0041 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -9,8 +9,8 @@ import io.metersphere.commons.utils.PageUtils; 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.member.QueryMemberRequest; import io.metersphere.controller.request.organization.AddOrgMemberRequest; import io.metersphere.controller.request.organization.QueryOrgMemberRequest; import io.metersphere.dto.UserDTO; @@ -250,13 +250,15 @@ public class UserController { public List getBesideOrgMemberList(@PathVariable String orgId) { return userService.getBesideOrgMemberList(orgId); } + /* - * 修改当前用户密码 - * */ + * 修改当前用户密码 + * */ @PostMapping("/update/password") public int updateCurrentUserPassword(@RequestBody EditPassWordRequest request) { return userService.updateCurrentUserPassword(request); } + /*管理员修改用户密码*/ @PostMapping("/special/password") public int updateUserPassword(@RequestBody EditPassWordRequest request) { diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index b56ed617a3..7c0d9a2ead 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -277,12 +277,13 @@ public class UserService { userMapper.updateByPrimaryKeySelective(newUser); } + /*修改当前用户用户密码*/ private User updateCurrentUserPwd(EditPassWordRequest request) { if (SessionUtils.getUser() != null) { User user = userMapper.selectByPrimaryKey(SessionUtils.getUser().getId()); String pwd = user.getPassword(); - String prepwd = CodingUtil.md5(request.getPassword(),"utf-8"); + String prepwd = CodingUtil.md5(request.getPassword(), "utf-8"); String newped = request.getNewpassword(); if (StringUtils.isNotBlank(prepwd)) { if (prepwd.trim().equals(pwd.trim())) { @@ -300,16 +301,18 @@ public class UserService { User user = updateCurrentUserPwd(request); return extUserMapper.updatePassword(user); } + /*管理员修改用户密码*/ - private User updateUserPwd(EditPassWordRequest request){ - User user= userMapper.selectByPrimaryKey(request.getId()); + 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(EditPassWordRequest request){ - User user=updateUserPwd(request); + + public int updateUserPassword(EditPassWordRequest request) { + User user = updateUserPwd(request); return extUserMapper.updatePassword(user); }