mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 08:13:44 +08:00 
			
		
		
		
	update 优化 部门下存在岗位不允许删除
This commit is contained in:
		@@ -12,6 +12,7 @@ import org.dromara.common.web.core.BaseController;
 | 
				
			|||||||
import org.dromara.system.domain.bo.SysDeptBo;
 | 
					import org.dromara.system.domain.bo.SysDeptBo;
 | 
				
			||||||
import org.dromara.system.domain.vo.SysDeptVo;
 | 
					import org.dromara.system.domain.vo.SysDeptVo;
 | 
				
			||||||
import org.dromara.system.service.ISysDeptService;
 | 
					import org.dromara.system.service.ISysDeptService;
 | 
				
			||||||
 | 
					import org.dromara.system.service.ISysPostService;
 | 
				
			||||||
import org.springframework.validation.annotation.Validated;
 | 
					import org.springframework.validation.annotation.Validated;
 | 
				
			||||||
import org.springframework.web.bind.annotation.*;
 | 
					import org.springframework.web.bind.annotation.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -29,6 +30,7 @@ import java.util.List;
 | 
				
			|||||||
public class SysDeptController extends BaseController {
 | 
					public class SysDeptController extends BaseController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final ISysDeptService deptService;
 | 
					    private final ISysDeptService deptService;
 | 
				
			||||||
 | 
					    private final ISysPostService postService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 获取部门列表
 | 
					     * 获取部门列表
 | 
				
			||||||
@@ -117,6 +119,9 @@ public class SysDeptController extends BaseController {
 | 
				
			|||||||
        if (deptService.checkDeptExistUser(deptId)) {
 | 
					        if (deptService.checkDeptExistUser(deptId)) {
 | 
				
			||||||
            return R.warn("部门存在用户,不允许删除");
 | 
					            return R.warn("部门存在用户,不允许删除");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        if (postService.countPostByDeptId(deptId) > 0) {
 | 
				
			||||||
 | 
					            return R.warn("部门存在岗位,不允许删除");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        deptService.checkDeptDataScope(deptId);
 | 
					        deptService.checkDeptDataScope(deptId);
 | 
				
			||||||
        return toAjax(deptService.deleteDeptById(deptId));
 | 
					        return toAjax(deptService.deleteDeptById(deptId));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,6 +80,14 @@ public interface ISysPostService {
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    long countUserPostById(Long postId);
 | 
					    long countUserPostById(Long postId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 通过部门ID查询岗位使用数量
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param deptId 部门id
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    long countPostByDeptId(Long deptId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 删除岗位信息
 | 
					     * 删除岗位信息
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -177,6 +177,17 @@ public class SysPostServiceImpl implements ISysPostService {
 | 
				
			|||||||
        return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId, postId));
 | 
					        return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId, postId));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 通过部门ID查询岗位使用数量
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param deptId 部门id
 | 
				
			||||||
 | 
					     * @return 结果
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public long countPostByDeptId(Long deptId) {
 | 
				
			||||||
 | 
					        return baseMapper.selectCount(new LambdaQueryWrapper<SysPost>().eq(SysPost::getDeptId, deptId));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 删除岗位信息
 | 
					     * 删除岗位信息
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user