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/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-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/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 832a68b0a..f7ad60f10 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 @@ - + + +