From af76be07c9bf9efa3677e09c97a658b46706a04b Mon Sep 17 00:00:00 2001 From: cheney <1251790704@qq.com> Date: Mon, 27 Mar 2023 15:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E9=87=8D=E8=BF=94=E5=9B=9E=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/code/BaseResponseCode.java | 1 + .../iasf/controller/UserGroupController.java | 4 +-- .../java/com/huoran/iasf/entity/SysDept.java | 7 ++--- .../com/huoran/iasf/entity/UserGroup.java | 1 + .../huoran/iasf/mapper/xml/SysFilesMapper.xml | 8 +++--- .../iasf/service/impl/DeptServiceImpl.java | 28 +++++++++++++------ 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java b/src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java index bf576b6..b41faea 100644 --- a/src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java +++ b/src/main/java/com/huoran/iasf/common/exception/code/BaseResponseCode.java @@ -45,6 +45,7 @@ public enum BaseResponseCode implements ResponseCodeInterface { ROLE_PERMISSION_RELATION(401009, "该菜单权限存在子集关联,不允许删除"), OLD_PASSWORD_ERROR(401010, "旧密码不正确"), NOT_PERMISSION_DELETED_DEPT(401011, "该组织机构下还关联着用户,不允许删除"), + DELETE_SUB_DEPARTMENTS_FIRST(401018, "请先删除子级部门!"), OPERATION_MENU_PERMISSION_CATALOG_ERROR(401012, "操作后的菜单类型是目录,所属菜单必须为默认顶级菜单或者目录"), OPERATION_MENU_PERMISSION_MENU_ERROR(401013, "操作后的菜单类型是菜单,所属菜单必须为目录类型"), OPERATION_MENU_PERMISSION_BTN_ERROR(401013, "操作后的菜单类型是按钮,所属菜单必须为菜单类型"), diff --git a/src/main/java/com/huoran/iasf/controller/UserGroupController.java b/src/main/java/com/huoran/iasf/controller/UserGroupController.java index b098670..a17a493 100644 --- a/src/main/java/com/huoran/iasf/controller/UserGroupController.java +++ b/src/main/java/com/huoran/iasf/controller/UserGroupController.java @@ -45,7 +45,7 @@ public class UserGroupController { UserGroup one = userGroupService.getOne(new QueryWrapper(). eq("group_name", userGroup.getGroupName())); if (ObjectUtil.isNotNull(one)){ - R.fail("用户组已存在"); + return R.fail("用户组已存在"); } userGroupService.save(userGroup); return R.success(); @@ -73,7 +73,7 @@ public class UserGroupController { queryWrapper.last(" and id != " + userGroup.getId()); List groups = userGroupService.list(queryWrapper); if (ObjectUtil.isNotNull(groups) && groups.size()>0){ - R.fail("用户组已存在"); + return R.fail("用户组已存在"); } userGroupService.updateById(userGroup); return R.success(); diff --git a/src/main/java/com/huoran/iasf/entity/SysDept.java b/src/main/java/com/huoran/iasf/entity/SysDept.java index b83727b..cbf3020 100644 --- a/src/main/java/com/huoran/iasf/entity/SysDept.java +++ b/src/main/java/com/huoran/iasf/entity/SysDept.java @@ -1,9 +1,6 @@ package com.huoran.iasf.entity; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.*; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -60,7 +57,7 @@ public class SysDept implements Serializable { @TableField(fill = FieldFill.INSERT_UPDATE) private Date updateTime; - @TableField(fill = FieldFill.INSERT) + @TableLogic private Integer deleted; } \ No newline at end of file diff --git a/src/main/java/com/huoran/iasf/entity/UserGroup.java b/src/main/java/com/huoran/iasf/entity/UserGroup.java index d04e2c0..c7e22c3 100644 --- a/src/main/java/com/huoran/iasf/entity/UserGroup.java +++ b/src/main/java/com/huoran/iasf/entity/UserGroup.java @@ -47,6 +47,7 @@ public class UserGroup extends BaseEntity implements Serializable { private Date updateTime; @ApiModelProperty(value = "是否删除(1未删除;0已删除)") + @TableLogic private Integer deleted; } diff --git a/src/main/java/com/huoran/iasf/mapper/xml/SysFilesMapper.xml b/src/main/java/com/huoran/iasf/mapper/xml/SysFilesMapper.xml index 12e4792..d38b95e 100644 --- a/src/main/java/com/huoran/iasf/mapper/xml/SysFilesMapper.xml +++ b/src/main/java/com/huoran/iasf/mapper/xml/SysFilesMapper.xml @@ -24,13 +24,13 @@ FROM sys_files f LEFT JOIN sys_user u ON f.uploader = u.id - WHERE - - AND f.site = 1 - AND f.deleted = 1 + WHERE f.deleted = 1 AND f.is_release = 1 AND f.is_del = 0 and f.quote is not null + + AND f.site = #{req.site} + AND f.type = #{req.type} diff --git a/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java b/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java index 29bd997..f0c49a4 100644 --- a/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java +++ b/src/main/java/com/huoran/iasf/service/impl/DeptServiceImpl.java @@ -86,12 +86,12 @@ public class DeptServiceImpl extends ServiceImpl impleme } sysDeptMapper.updateById(vo); //说明层级发生了变化 - if (!StringUtils.isEmpty(vo.getPid()) && !vo.getPid().equals(sysDept.getPid())) { + /*if (!StringUtils.isEmpty(vo.getPid()) && !vo.getPid().equals(sysDept.getPid())) { SysDept parent = sysDeptMapper.selectById(vo.getPid()); if (!"0".equals(vo.getPid()) && null == parent) { throw new BusinessException(BaseResponseCode.DATA_ERROR); } - /*SysDept oldParent = sysDeptMapper.selectById(sysDept.getPid()); + *//*SysDept oldParent = sysDeptMapper.selectById(sysDept.getPid()); String oldRelationCode; String newRelationCode; //根目录降到其他目录 @@ -104,16 +104,16 @@ public class DeptServiceImpl extends ServiceImpl impleme } else { oldRelationCode = oldParent.getRelationCode(); newRelationCode = parent.getRelationCode(); - }*/ - /*LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); + }*//* + *//*LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(); wrapper.likeLeft(SysDept::getDeptNo, sysDept.getDeptNo()); List list = sysDeptMapper.selectList(wrapper); list.parallelStream().forEach(entity -> { String relationCode = entity.getRelationCode().replace(oldRelationCode, newRelationCode); entity.setRelationCode(relationCode); sysDeptMapper.updateById(entity); - });*/ - } + });*//* + }*/ } @Override @@ -124,9 +124,19 @@ public class DeptServiceImpl extends ServiceImpl impleme } List deptIds = sysDeptMapper.selectObjs(Wrappers.lambdaQuery().select(SysDept::getId).likeRight(SysDept::getRelationCode, sysDept.getRelationCode())); - List list = userDeptMapper.selectList(Wrappers.lambdaQuery().in(UserDept::getDeptId, deptIds)); - if (!CollectionUtils.isEmpty(list)) { - throw new BusinessException(BaseResponseCode.NOT_PERMISSION_DELETED_DEPT); + if (deptIds!=null&&deptIds.size()>0){ + List list = userDeptMapper.selectList(Wrappers.lambdaQuery().in(UserDept::getDeptId, deptIds)); + if (!CollectionUtils.isEmpty(list)) { + throw new BusinessException(BaseResponseCode.NOT_PERMISSION_DELETED_DEPT); + } + }else { + //查询是否有子级部门 + QueryWrapper deptQueryWrapper = new QueryWrapper<>(); + deptQueryWrapper.eq("pid",sysDept.getId()); + List sysDepts = sysDeptMapper.selectList(deptQueryWrapper); + if (sysDepts!=null&& sysDepts.size()>0){ + throw new BusinessException(BaseResponseCode.DELETE_SUB_DEPARTMENTS_FIRST); + } } sysDeptMapper.deleteById(id); }