Browse Source

DeBugDeBugDeBug

buzhanyi 2 years ago
parent
commit
323355f233

+ 10 - 0
purchase-admin/src/main/java/com/ozs/web/controller/system/SysDeptController.java

@@ -50,6 +50,16 @@ public class SysDeptController extends BaseController {
         return success(depts);
         return success(depts);
     }
     }
 
 
+    /**
+     * 获取部门列表
+     */
+    @GetMapping("/listAndUp")
+    @ApiOperation("获取部门列表")
+    public AjaxResult listAndUp(SysDept dept) {
+        List<SysDept> depts = deptService.selectDeptListAndUp(dept);
+        return success(depts);
+    }
+
     /**
     /**
      * 获取部门列表
      * 获取部门列表
      */
      */

+ 8 - 0
purchase-system/src/main/java/com/ozs/system/service/ISysDeptService.java

@@ -22,6 +22,14 @@ public interface ISysDeptService {
      */
      */
     public List<SysDept> selectDeptList(SysDept dept);
     public List<SysDept> selectDeptList(SysDept dept);
 
 
+    /**
+     * 查询部门管理数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    public List<SysDept> selectDeptListAndUp(SysDept dept);
+
     /**
     /**
      * 查询部门树结构信息
      * 查询部门树结构信息
      *
      *

+ 30 - 0
purchase-system/src/main/java/com/ozs/system/service/impl/SysDeptServiceImpl.java

@@ -79,6 +79,36 @@ public class SysDeptServiceImpl implements ISysDeptService {
         return deptMapper.selectDeptList(dept);
         return deptMapper.selectDeptList(dept);
     }
     }
 
 
+    /**
+     * 查询部门管理数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    @Override
+    @DataScope(deptAlias = "d")
+    public List<SysDept> selectDeptListAndUp(SysDept dept) {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        if (!String.valueOf(loginUser.getUserId()).equals("1")) {
+            List<Long> deptList = new ArrayList<>();
+            //获取到子孙级部门id
+            Long deptId = loginUser.getDeptId();
+            if (deptService.hasChildByDeptId(deptId)) {
+                List<Long> children = deptService.getDeptChildren(deptId);
+                System.err.println(children.size());
+                deptList.addAll(children);
+            }
+            //查询上一级
+            SysDept sysDept = deptService.selectByCid(loginUser.getDeptId());
+            if (!ObjectUtils.isEmpty(sysDept)) {
+                deptList.add(sysDept.getDeptId());
+            }
+            deptList.add(deptId);
+            dept.setDeptList(deptList);
+        }
+        return deptMapper.selectDeptList(dept);
+    }
+
     /**
     /**
      * 查询部门树结构信息
      * 查询部门树结构信息
      *
      *