zhanglinxin 1 year ago
parent
commit
15068ddcbd

+ 19 - 17
application/api/controller/Dingtalk.php

@@ -57,23 +57,25 @@ class Dingtalk extends Base
     {
         $dept_id = input('dept_id');
         $resp = DingtalkService::user_list($dept_id);
-//        $data = [];
-//        foreach ($resp->list as $value) {
-//            $data[] = [
-//                'userid' => $value->userid,
-//                'unionid' => $value->unionid,
-//                'name' => $value->name,
-//                'avatar' => $value->avatar,
-//                'mobile' => isset($value->mobile) ? $value->mobile : '',
-//                'email' => isset($value->email) ? $value->email : '',
-//                'title' => $value->title,
-//                'manager_userid' => isset($value->manager_userid) ? $value->manager_userid : '',
-//                'department' => implode(',', $value->dept_id_list),
-//            ];
-//        }
-//        if ($data) {
-//            User::insertAll($data);
-//        }
+        if($resp->list){
+            $data = [];
+            foreach ($resp->list as $value) {
+                $data[] = [
+                    'userid' => $value->userid,
+                    'unionid' => $value->unionid,
+                    'name' => $value->name,
+                    'avatar' => $value->avatar,
+                    'mobile' => isset($value->mobile) ? $value->mobile : '',
+                    'email' => isset($value->email) ? $value->email : '',
+                    'title' => $value->title,
+                    'manager_userid' => isset($value->manager_userid) ? $value->manager_userid : '',
+                    'department' => implode(',', $value->dept_id_list),
+                ];
+            }
+            if ($data) {
+                User::insertAll($data);
+            }
+        }
         $this->success('获取部门用户详情', $resp);
     }
 

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

@@ -73,10 +73,9 @@ class DingtalkService
         $req->setCursor("0");
         $req->setSize("100");
         $resp = $c->execute($req, $accessToken, "https://oapi.dingtalk.com/topapi/v2/user/list");
-        p($resp);exit;
         if($resp->errcode == 0 && $resp->errmsg == 'ok'){
             $result = $resp->result;
-            return $resp;
+            return $result;
         }
         except($resp->errcode.' '.$resp->errmsg);
     }