From 46c56f3918855043c32c9013266c9b3c95e29309 Mon Sep 17 00:00:00 2001 From: laker <935009066@qq.com> Date: Wed, 25 Aug 2021 14:51:19 +0800 Subject: [PATCH] =?UTF-8?q?(=E6=96=B0=E5=A2=9E)[=E6=95=B4=E4=BD=93](?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=86=E7=A0=81=E3=80=81=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E8=B5=84=E6=96=99)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/controller/LoginController.java | 11 +- .../sys/controller/SysUserController.java | 24 +++ .../admin/module/sys/entity/SysUser.java | 3 +- .../laker/admin/module/sys/pojo/PwdQo.java | 10 ++ web/admin/admin/css/other/center.css | 80 +++++++++ web/admin/index.html | 4 +- web/admin/view/system/user/center.html | 166 ++++++++++++++++++ web/admin/view/system/user/password.html | 81 +++++++++ web/admin/view/system/user/profile.html | 120 +++++++++++++ 9 files changed, 496 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/laker/admin/module/sys/pojo/PwdQo.java create mode 100644 web/admin/admin/css/other/center.css create mode 100644 web/admin/view/system/user/center.html create mode 100644 web/admin/view/system/user/password.html create mode 100644 web/admin/view/system/user/profile.html diff --git a/src/main/java/com/laker/admin/module/sys/controller/LoginController.java b/src/main/java/com/laker/admin/module/sys/controller/LoginController.java index daf7cdd..6ddfb82 100644 --- a/src/main/java/com/laker/admin/module/sys/controller/LoginController.java +++ b/src/main/java/com/laker/admin/module/sys/controller/LoginController.java @@ -20,9 +20,11 @@ import com.laker.admin.framework.cache.ICache; import com.laker.admin.framework.ext.mybatis.UserInfoAndPowers; import com.laker.admin.framework.ext.satoken.MySaTokenListener; import com.laker.admin.framework.ext.satoken.OnlineUser; +import com.laker.admin.module.sys.entity.SysDept; import com.laker.admin.module.sys.entity.SysRole; import com.laker.admin.module.sys.entity.SysUser; import com.laker.admin.module.sys.entity.SysUserRole; +import com.laker.admin.module.sys.service.ISysDeptService; import com.laker.admin.module.sys.service.ISysRoleService; import com.laker.admin.module.sys.service.ISysUserRoleService; import com.laker.admin.module.sys.service.ISysUserService; @@ -52,6 +54,8 @@ public class LoginController { ISysUserRoleService sysUserRoleService; @Autowired ISysRoleService sysRoleService; + @Autowired + ISysDeptService sysDeptService; @PostMapping("/api/v1/login") @ApiOperationSupport(order = 1) @@ -103,7 +107,12 @@ public class LoginController { @ApiOperationSupport(order = 2) @ApiOperation(value = "获取当前用户信息") public Response userInfo() { - return Response.ok(sysUserService.getById(StpUtil.getLoginIdAsLong())); + SysUser user = sysUserService.getById(StpUtil.getLoginIdAsLong()); + SysDept dept = sysDeptService.getById(user.getDeptId()); + if (dept != null) { + user.setDeptName(dept.getDeptName()); + } + return Response.ok(user); } @GetMapping("/api/v1/onlineUsers") diff --git a/src/main/java/com/laker/admin/module/sys/controller/SysUserController.java b/src/main/java/com/laker/admin/module/sys/controller/SysUserController.java index 8085f6e..e14ad28 100644 --- a/src/main/java/com/laker/admin/module/sys/controller/SysUserController.java +++ b/src/main/java/com/laker/admin/module/sys/controller/SysUserController.java @@ -14,6 +14,7 @@ import com.laker.admin.framework.aop.Metrics; import com.laker.admin.module.sys.entity.SysRole; import com.laker.admin.module.sys.entity.SysUser; import com.laker.admin.module.sys.entity.SysUserRole; +import com.laker.admin.module.sys.pojo.PwdQo; import com.laker.admin.module.sys.service.ISysRoleService; import com.laker.admin.module.sys.service.ISysUserRoleService; import com.laker.admin.module.sys.service.ISysUserService; @@ -102,6 +103,29 @@ public class SysUserController { return sysUserRoleService.saveBatch(sysUserRoles); } + + @PutMapping("/updatePwd") + @ApiOperation(value = "更新用户密码") + @SaCheckPermission("user.update.pwd") + public Response updatePwd(@RequestBody PwdQo param) { + + if (!StrUtil.equals(param.getNewPassword(), param.getConfirmPassword())) { + return Response.error("500", "两次输入密码不一致"); + } + long userId = StpUtil.getLoginIdAsLong(); + SysUser sysUser = sysUserService.getOne(Wrappers.lambdaQuery() + .eq(SysUser::getUserId, userId) + .eq(SysUser::getPassword, SecureUtil.sha256(param.getOldPassword()))); + if (sysUser == null) { + return Response.error("500", "用户名密码错误"); + } + SysUser user = new SysUser(); + user.setUserId(userId); + user.setPassword(SecureUtil.sha256(param.getNewPassword())); + sysUserService.updateById(user); + return Response.ok(); + } + @GetMapping("/{id}") @ApiOperation(value = "根据id查询") public Response get(@PathVariable Long id) { diff --git a/src/main/java/com/laker/admin/module/sys/entity/SysUser.java b/src/main/java/com/laker/admin/module/sys/entity/SysUser.java index 627ceba..43840d8 100644 --- a/src/main/java/com/laker/admin/module/sys/entity/SysUser.java +++ b/src/main/java/com/laker/admin/module/sys/entity/SysUser.java @@ -38,7 +38,8 @@ public class SysUser implements Serializable { private Long deptId; @TableField(exist = false) private SysDept dept; - + @TableField(exist = false) + private String deptName; private Integer sex; private String phone; diff --git a/src/main/java/com/laker/admin/module/sys/pojo/PwdQo.java b/src/main/java/com/laker/admin/module/sys/pojo/PwdQo.java new file mode 100644 index 0000000..d4b179a --- /dev/null +++ b/src/main/java/com/laker/admin/module/sys/pojo/PwdQo.java @@ -0,0 +1,10 @@ +package com.laker.admin.module.sys.pojo; + +import lombok.Data; + +@Data +public class PwdQo { + private String oldPassword; + private String newPassword; + private String confirmPassword; +} \ No newline at end of file diff --git a/web/admin/admin/css/other/center.css b/web/admin/admin/css/other/center.css new file mode 100644 index 0000000..53c787a --- /dev/null +++ b/web/admin/admin/css/other/center.css @@ -0,0 +1,80 @@ +.pear-container { + background-color: whitesmoke; + margin: 10px; +} +.layui-body { + padding: 25px; +} +.text-center { + text-align: center; +} +.user-info-head { + width: 110px; + height: 110px; + line-height: 110px; + position: relative; + display: inline-block; + border-radius: 50%; + overflow: hidden; + cursor: pointer; + margin: 0 auto; +} +.layui-line-dash { + border-bottom: 1px dashed #ccc; + margin: 15px 0; +} +.comment { + position: absolute; + bottom: 3px; + right: 10px; + font-size: 12px; + color: dimgray; +} +.content { + padding-left: 13px; + font-size: 13px; + color: dimgray; +} +.title { + padding-left: 13.5px; +} +.layui-tab-title { + border-bottom: none; +} +.fl-item { + height: 30px; + font-size: 13.5; +} +.dot { + width: 10px; + height: 10px; + border-radius: 50px; + background-color: gray; + display: inline-block; + margin-right: 10px; +} + +.list .list-item { + height: 32px; + line-height: 32px; + color: gray; + padding: 5px; + padding-left: 15px; + border-radius: 4px; + margin-top: 5.2px; +} + +.list .list-item:hover { + background-color: whitesmoke; +} + +.list .list-item .title { + font-size: 13px; + width: 100%; +} + +.list .list-item .footer { + position: absolute; + right: 30px; + font-size: 12px; +} diff --git a/web/admin/index.html b/web/admin/index.html index 3894942..c74cfe4 100644 --- a/web/admin/index.html +++ b/web/admin/index.html @@ -37,7 +37,9 @@
-
基本资料 +
基本资料 +
+
修改密码
注销登录
diff --git a/web/admin/view/system/user/center.html b/web/admin/view/system/user/center.html new file mode 100644 index 0000000..def2c15 --- /dev/null +++ b/web/admin/view/system/user/center.html @@ -0,0 +1,166 @@ + + + + + Title + + + + + +
+
+
+
+
+ +

头像

+
+
+
+
+
+
+
个人信息
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ + + + + diff --git a/web/admin/view/system/user/password.html b/web/admin/view/system/user/password.html new file mode 100644 index 0000000..99b34dd --- /dev/null +++ b/web/admin/view/system/user/password.html @@ -0,0 +1,81 @@ + + + + + + + +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + +
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/web/admin/view/system/user/profile.html b/web/admin/view/system/user/profile.html new file mode 100644 index 0000000..8c17b5d --- /dev/null +++ b/web/admin/view/system/user/profile.html @@ -0,0 +1,120 @@ + + + + + + + +
+
+
+ +
+
+
+
+
+
+
+
+
+
+ + + + + +
+
建议:图片的尺寸宽高比为1:1,大小在5m以内。
+
+
+ + + + \ No newline at end of file -- GitLab