From 34a4ec4b26a369eb0f71ebbbdda8b631acf0d5cf Mon Sep 17 00:00:00 2001 From: zhangzhiqiang Date: Wed, 7 Dec 2022 16:55:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BF=AE=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) }) }) } From e22f3008b1b4925f7a641514874c70e13da9bbb7 Mon Sep 17 00:00:00 2001 From: zhangzhiqiang Date: Wed, 7 Dec 2022 18:38:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?mdf:=E9=83=A8=E9=97=A8=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nl/sso/system/rest/DeptController.java | 16 +++-- .../src/views/system/dept/index.vue | 63 +++++++++++-------- .../src/views/system/user/index.vue | 11 ++-- 3 files changed, 53 insertions(+), 37 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/DeptController.java b/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/DeptController.java index 16c26be11..7276e421f 100644 --- a/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/DeptController.java +++ b/lms/nladmin-system/src/main/java/org/nl/sso/system/rest/DeptController.java @@ -17,13 +17,12 @@ package org.nl.sso.system.rest; import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaMode; -import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; -import org.nl.modules.common.exception.BadRequestException; +import org.apache.commons.lang3.StringUtils; import org.nl.modules.common.utils.PageUtil; import org.nl.modules.logging.annotation.Log; import org.nl.sso.system.domain.Dept; @@ -66,8 +65,18 @@ public class DeptController { if (criteria.getPid() == null){ criteria.setPidIsNull(true); } + Boolean hasChild = false; + if (StringUtils.isNotEmpty(criteria.getName()) || StringUtils.isNotEmpty(criteria.getIs_used())){ + criteria.setPidIsNull(null); + hasChild=true; + } List deptDtos = deptService.queryAll(criteria, true); List deptVos = CopyUtil.copyList(deptDtos, DeptVo.class); + if (hasChild){ + deptVos.forEach(a->{ + a.setHasChildren(false); + }); + } return new ResponseEntity<>(PageUtil.toPage(deptVos, deptVos.size()),HttpStatus.OK); } @@ -101,9 +110,6 @@ public class DeptController { @PostMapping // @SaCheckPermission("dept:add") public ResponseEntity create(@Validated @RequestBody Dept resources){ - if (resources.getDept_id() != null) { - throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); - } deptService.create(resources); return new ResponseEntity<>(HttpStatus.CREATED); } diff --git a/lms/nladmin-ui/src/views/system/dept/index.vue b/lms/nladmin-ui/src/views/system/dept/index.vue index 17409c6b7..63ebcd416 100644 --- a/lms/nladmin-ui/src/views/system/dept/index.vue +++ b/lms/nladmin-ui/src/views/system/dept/index.vue @@ -37,7 +37,7 @@ width="500px" > - + @@ -103,34 +103,28 @@ - + @@ -182,12 +176,18 @@ export default { del: ['admin', 'dept:del'] }, enabledTypeOptions: [ - { key: '1', display_name: '正常' }, + { key: '1', display_name: '启用' }, { key: '0', display_name: '禁用' } ] } }, methods: { + caseStatusColorFilter(is_used) { + if (is_used === '1') { + return '#378be2' + } + return '#F56C6C' + }, getDeptDatas(tree, treeNode, resolve) { const params = { pid: tree.dept_id } setTimeout(() => { @@ -266,20 +266,29 @@ export default { return true }, // 改变状态 - changeEnabled(data, val) { - this.$confirm('此操作将 "' + this.dict.label.dept_status[val] + '" ' + data.name + '部门, 是否继续?', '提示', { + changeEnabled(row) { + const satus = this.enabledTypeOptions.find(item => { return item.key !== row.is_used }) + this.$confirm('此操作将' + satus.display_name + '部门:' + row.name + ', 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { - crudDept.edit(data).then(res => { - this.crud.notify(this.dict.label.dept_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS) - }).catch(err => { - data.enabled = !data.enabled - console.log(err.response.data.message) + row.is_used = satus.key + crudDept.edit(row).then(res => { + this.crud.toQuery() + this.crud.notify('部门' + row.name + '已' + satus.display_name) }) + }) + }, + handdeleted(datas) { + this.$confirm(`删除该部门将连带删除所有子部门,确认删除?`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.crud.delAllLoading = true + this.crud.doDelete(datas) }).catch(() => { - data.enabled = !data.enabled }) }, checkboxT(row, rowIndex) { diff --git a/lms/nladmin-ui/src/views/system/user/index.vue b/lms/nladmin-ui/src/views/system/user/index.vue index 645774fa9..c8c34bd4c 100644 --- a/lms/nladmin-ui/src/views/system/user/index.vue +++ b/lms/nladmin-ui/src/views/system/user/index.vue @@ -168,7 +168,7 @@ width="200" >