From 9a915a89419aaba84f2e719569842cb59c4c0574 Mon Sep 17 00:00:00 2001 From: Parker Date: Thu, 24 Dec 2020 11:54:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E7=BD=AE=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../opsli/api/web/system/user/UserApi.java | 7 +++++ .../system/user/service/IUserService.java | 7 +++++ .../user/service/impl/UserServiceImpl.java | 31 +++++++++++++++++++ .../system/user/web/UserRestController.java | 25 +++++++++++++++ .../src/main/resources/application.yaml | 3 ++ 5 files changed, 73 insertions(+) diff --git a/opsli-api/src/main/java/org/opsli/api/web/system/user/UserApi.java b/opsli-api/src/main/java/org/opsli/api/web/system/user/UserApi.java index 62c6813b..689c222a 100644 --- a/opsli-api/src/main/java/org/opsli/api/web/system/user/UserApi.java +++ b/opsli-api/src/main/java/org/opsli/api/web/system/user/UserApi.java @@ -102,6 +102,13 @@ public interface UserApi { @PostMapping("/updatePasswordById") ResultVo updatePasswordById(@RequestBody UserPassword userPassword); + /** + * 重置密码 ID + * @return ResultVo + */ + @PostMapping("/resetPasswordById") + ResultVo resetPasswordById(String userId); + /** * 上传头像 diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/IUserService.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/IUserService.java index 9a497cd5..2451aa71 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/IUserService.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/IUserService.java @@ -80,6 +80,13 @@ public interface IUserService extends CrudServiceInterface { */ boolean updatePassword(UserPassword userPassword); + /** + * 重置密码 + * @param userPassword + * @return + */ + boolean resetPassword(UserPassword userPassword); + /** * 更新用户最后登录IP diff --git a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/impl/UserServiceImpl.java b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/impl/UserServiceImpl.java index 5aec8e71..2ba5b3b4 100644 --- a/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/impl/UserServiceImpl.java +++ b/opsli-modulars/opsli-modulars-system/src/main/java/org/opsli/modulars/system/user/service/impl/UserServiceImpl.java @@ -230,6 +230,37 @@ public class UserServiceImpl extends CrudServiceImpl resetPasswordById(String userId) { + // 演示模式 不允许操作 + super.demoError(); + + UserPassword userPassword = new UserPassword(); + userPassword.setNewPassword(defaultPass); + userPassword.setUserId(userId); + boolean resetPasswordFlag = IService.resetPassword(userPassword); + if(!resetPasswordFlag){ + return ResultVo.error("重置密码失败"); + } + + return ResultVo.success("重置密码成功!默认密码为:" + defaultPass); + } /** * 用户信息 查一条 diff --git a/opsli-starter/src/main/resources/application.yaml b/opsli-starter/src/main/resources/application.yaml index 0e11339e..3a721347 100644 --- a/opsli-starter/src/main/resources/application.yaml +++ b/opsli-starter/src/main/resources/application.yaml @@ -186,6 +186,9 @@ opsli: # token 有效时间 (分钟) 2小时 token-effective-time: 120 + # 重置默认密码 + default-pass: Aa123456 + # 登录设置 login: # 失败次数