From 34a4ec4b26a369eb0f71ebbbdda8b631acf0d5cf Mon Sep 17 00:00:00 2001 From: zhangzhiqiang Date: Wed, 7 Dec 2022 16:55:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=A1=B5=E9=9D=A2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/sso/system/domain/vo/UserVo.java | 4 ++ .../system/service/impl/UserServiceImpl.java | 35 +++++++---- .../src/views/system/user/index.vue | 63 +++++++++---------- 3 files changed, 54 insertions(+), 48 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/vo/UserVo.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/vo/UserVo.java index f3de74044..e992d6c73 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/vo/UserVo.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/domain/vo/UserVo.java @@ -97,4 +97,8 @@ public class UserVo extends BaseDto implements Serializable { this.depts = Arrays.stream(split).map(a->Long.valueOf(a)).collect(Collectors.toList()); } } + + public void setPassword(String password) { + this.password = null; + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/UserServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/UserServiceImpl.java index ce8ba39f7..e21b9b741 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/UserServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/service/impl/UserServiceImpl.java @@ -146,9 +146,12 @@ public class UserServiceImpl implements UserService { List depts = resources.getDepts(); List roles = resources.getRoles(); JSONObject currentUser = WQLObject.getWQLObject("sys_user").query("username = '" + resources.getUsername() + "'").uniqueResult(0); - - userRelateService.inserDeptRelate(currentUser.getLong("user_id"),new HashSet(depts)); - userRelateService.inserRoleRelate(currentUser.getLong("user_id"),new HashSet(roles)); + if (!CollectionUtils.isEmpty(depts)){ + userRelateService.inserDeptRelate(currentUser.getLong("user_id"),new HashSet(depts)); + } + if (!CollectionUtils.isEmpty(roles)){ + userRelateService.inserRoleRelate(currentUser.getLong("user_id"),new HashSet(roles)); + } } @@ -162,7 +165,9 @@ public class UserServiceImpl implements UserService { if("0".equals(resources.getIs_used())){ onlineUserService.kickOutForUsername(resources.getUsername()); } - resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt")); + if (StringUtils.isNotEmpty(resources.getPassword())){ + resources.setPassword(SaSecureUtil.md5BySalt(resources.getPassword(), "salt")); + } resources.setUpdate_time(new Date()); resources.setUpdate_optid(user.getId()); resources.setUpdate_optname(user.getUsername()); @@ -172,16 +177,20 @@ public class UserServiceImpl implements UserService { //更新部门用户 List depts = resources.getDepts(); List roles = resources.getRoles(); - userRelateService.updateDeptRelate(resources.getUser_id(),new HashSet(depts)); - userRelateService.updateRoleRelate(resources.getUser_id(),new HashSet(roles)); - - - // 如果用户的角色改变 - if (!resources.getRoles().equals(user.getRoles())) { - redisUtils.del(CacheKey.DATA_USER + resources.getUser_id()); - redisUtils.del(CacheKey.MENU_USER + resources.getUser_id()); - redisUtils.del(CacheKey.ROLE_AUTH + resources.getUser_id()); + if (!CollectionUtils.isEmpty(depts)){ + userRelateService.updateDeptRelate(resources.getUser_id(),new HashSet(depts)); } + if (!CollectionUtils.isEmpty(roles)){ + userRelateService.updateRoleRelate(resources.getUser_id(),new HashSet(roles)); + // 如果用户的角色改变 + if (!resources.getRoles().equals(user.getRoles())) { + redisUtils.del(CacheKey.DATA_USER + resources.getUser_id()); + redisUtils.del(CacheKey.MENU_USER + resources.getUser_id()); + redisUtils.del(CacheKey.ROLE_AUTH + resources.getUser_id()); + } + } + + } diff --git a/lms/nladmin-ui/src/views/system/user/index.vue b/lms/nladmin-ui/src/views/system/user/index.vue index d28b5a915..964efedd5 100644 --- a/lms/nladmin-ui/src/views/system/user/index.vue +++ b/lms/nladmin-ui/src/views/system/user/index.vue @@ -155,13 +155,11 @@ - + + + 修改 删除 - + 更多 - 重置密码 - 部门权限 - 数据权限 - 锁定账号 - 分配角色 + 重置密码 + 部门权限 + 数据权限 + 锁定账号 + 分配角色 @@ -286,6 +284,12 @@ export default { } }) }, + caseStatusColorFilter(is_used) { + if (is_used === '1') { + return '#378be2' + } + return '#F56C6C' + }, handdeleted(datas) { this.$confirm(`确认删除选中的1条数据?`, '提示', { confirmButtonText: '确定', @@ -429,19 +433,17 @@ export default { this.crud.toQuery() }, // 改变状态 - changeEnabled(data, val) { - this.$confirm('此操作将 "' + this.dict.label.user_status[val] + '" ' + data.username + ', 是否继续?', '提示', { + changeEnabled(row) { + this.$confirm('此操作将停用账号:' + row.username + ', 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { - crudUser.edit(data).then(res => { - this.crud.notify(this.dict.label.user_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS) - }).catch(() => { - data.enabled = !data.enabled + row.is_used = '0' + crudUser.edit(row).then(res => { + this.crud.toQuery() + this.crud.notify('账号' + row.username + '已锁定') }) - }).catch(() => { - data.enabled = !data.enabled }) }, // 获取弹窗内角色数据 @@ -463,24 +465,15 @@ export default { return true }, resetPassword(row) { - row.password = null - this.$prompt('', '重置密码', { + this.$confirm(`确认重置密码?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', - inputPlaceholder: '请输入新的密码', - inputPattern: /^[A-Z|a-z|0-9|(._~!@#$^&*)]{6,20}$/, - inputErrorMessage: '密码格式不正确,只能是6-20位密码', - closeOnClickModal: false - }).then(({ value }) => { - row.password = value + type: 'warning' + }).then(() => { + row.password = '123456' crudUser.edit(row).then(res => { this.crud.toQuery() - this.crud.notify('密码重置成功', CRUD.NOTIFICATION_TYPE.SUCCESS) - }) - }).catch(() => { - this.$message({ - type: 'info', - message: '取消输入' + this.crud.notify('密码重置成功,密码:123456', CRUD.NOTIFICATION_TYPE.SUCCESS) }) }) }