疯狂的狮子li
2021-09-13 2af534eea471f4adb104906c7a814bcc66d4d68d
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -10,7 +10,6 @@
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
@@ -121,7 +120,7 @@
     * @return 子部门数
     */
    @Override
    public int selectNormalChildrenDeptById(Long deptId) {
    public long selectNormalChildrenDeptById(Long deptId) {
        return count(new LambdaQueryWrapper<SysDept>()
                .eq(SysDept::getStatus, 0)
                .apply("find_in_set({0}, ancestors)", deptId));
@@ -135,7 +134,7 @@
     */
    @Override
    public boolean hasChildByDeptId(Long deptId) {
        int result = count(new LambdaQueryWrapper<SysDept>()
        long result = count(new LambdaQueryWrapper<SysDept>()
                .eq(SysDept::getParentId, deptId)
                .last("limit 1"));
        return result > 0;
@@ -149,7 +148,7 @@
     */
    @Override
    public boolean checkDeptExistUser(Long deptId) {
        int result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>()
        long result = userMapper.selectCount(new LambdaQueryWrapper<SysUser>()
                .eq(SysUser::getDeptId, deptId));
        return result > 0;
    }
@@ -179,15 +178,12 @@
     * @param deptId 部门id
     */
    @Override
    public void checkDeptDataScope(Long deptId)
    {
        if (!SysUser.isAdmin(SecurityUtils.getUserId()))
        {
    public void checkDeptDataScope(Long deptId) {
        if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
            SysDept dept = new SysDept();
            dept.setDeptId(deptId);
            List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
            if (StringUtils.isEmpty(depts))
            {
            if (StringUtils.isEmpty(depts)) {
                throw new ServiceException("没有权限访问部门数据!");
            }
        }