Browse Source

DeBugDeBugDeBug

buzhanyi 2 years ago
parent
commit
cb0ac09aa1

+ 11 - 1
purchase-admin/src/main/java/com/ozs/web/controller/system/SysDeptController.java

@@ -51,7 +51,17 @@ public class SysDeptController extends BaseController {
     }
 
     /**
-     * 获取部门列表
+     * 获取部门列表(包含自己的祖级)
+     */
+    @GetMapping("/listAndF")
+    @ApiOperation("获取部门列表")
+    public AjaxResult listAndF(SysDept dept) {
+        List<SysDept> depts = deptService.selectDeptListAndF(dept);
+        return success(depts);
+    }
+
+    /**
+     * 获取部门列表(包含自己上一级)
      */
     @GetMapping("/listAndUp")
     @ApiOperation("获取部门列表")

+ 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);
 
+    /**
+     * 查询部门管理数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    public List<SysDept> selectDeptListAndF(SysDept dept);
+
     /**
      * 查询部门管理数据
      *

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

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