zhanglinxin 1 year ago
parent
commit
f51b93932b
1 changed files with 19 additions and 2 deletions
  1. 19 2
      application/common/service/DingtalkService.php

+ 19 - 2
application/common/service/DingtalkService.php

@@ -147,9 +147,26 @@ class DingtalkService
      **/
     public static function renew(){
 //        $department_list = UserService::get_department_column();
-        $data = self::department_listsub(1);
-        p($data);
+        $department_data = [];
+
+        p(self::get_tree(''));
 //        p($department_list);
         exit;
     }
+
+    /**
+     * 递归
+     **/
+    public static function get_tree($dept_id,&$tree = array()){
+        $resp = self::department_listsub($dept_id);
+        foreach ($resp as $value) {
+            $department_data[] = [
+                'dept_id' => $value->dept_id,
+                'name' => $value->name,
+                'parent_id' => $value->parent_id,
+            ];
+            self::get_tree($value->dept_id,$tree);
+        }
+        return $tree;
+    }
 }