浏览代码

1、企业类库 增加 移动部门方法 moveDepartment($data)

binsee 10 年之前
父节点
当前提交
bc56300a13
共有 4 个文件被更改,包括 66 次插入2 次删除
  1. 1 0
      README.md
  2. 32 1
      Thinkphp/qywechat.class.php
  3. 32 1
      qywechat.class.php
  4. 1 0
      wiki/企业号API类库.md

+ 1 - 0
README.md

@@ -262,6 +262,7 @@ $options = array(
 * createDepartment($data) 创建部门,参数: array("name"=>"邮箱产品组","parentid"=>"1","order" =>  "1")
 * updateDepartment($data) 更新部门,参数: array("id"=>"1","name"=>"邮箱产品组","parentid"=>"1","order" =>  "1")
 * deleteDepartment($id) 删除部门,参数:要删除的部门id
+* moveDepartment($data) 移动部门,参数:array("department_id" => "5","to_parentid" => "2","to_position" => "1")
 * getDepartment() 获取部门列表,返回部门数组。其中department部门列表数据。以部门的order字段从小到大排列
 * createUser($data) 创建成员,参数请看php文件内方法说明
 * updateUser($data) 更新成员,参数请看php文件内方法说明

+ 32 - 1
Thinkphp/qywechat.class.php

@@ -37,7 +37,8 @@ class Wechat
     const DEPARTMENT_CREATE_URL = '/department/create?';
     const DEPARTMENT_UPDATE_URL = '/department/update?';
     const DEPARTMENT_DELETE_URL = '/department/delete?';
-    const DEPARTMENT_LIST_URL = '/department/LIST?';
+    const DEPARTMENT_MOVE_URL = '/department/move?';
+    const DEPARTMENT_LIST_URL = '/department/list?';
     const TAG_CREATE_URL = '/tag/create?';
     const TAG_UPDATE_URL = '/tag/update?';
     const TAG_DELETE_URL = '/tag/delete?';
@@ -1006,6 +1007,36 @@ class Wechat
 	    }
 	    return false;
 	}
+
+	/**
+	 * 移动部门
+	 * @param $data
+	 * array(
+	 *    "department_id" => "5",	//所要移动的部门
+	 *    "to_parentid" => "2",		//想移动到的父部门节点,根部门为1
+	 *    "to_position" => "1"		//(非必须)想移动到的父部门下的位置,1表示最上方,往后位置为2,3,4,以此类推,默认为1
+	 * )
+	 * @return boolean|array 成功返回结果
+	 * {
+	 *   "errcode": 0,        //返回码
+	 *   "errmsg": "ok"  //对返回码的文本描述内容
+	 * }
+	 */
+	public function moveDepartment($data){
+	    if (!$this->access_token && !$this->checkAuth()) return false;
+	    $result = $this->http_get(self::API_URL_PREFIX.self::DEPARTMENT_MOVE_URL.'access_token='.$this->access_token,self::json_encode($data));
+	    if ($result)
+	    {
+	        $json = json_decode($result,true);
+	        if (!$json || !empty($json['errcode']) || $json['errcode']!=0) {
+	            $this->errCode = $json['errcode'];
+	            $this->errMsg = $json['errmsg'];
+	            return false;
+	        }
+	        return $json;
+	    }
+	    return false;
+	}
 	
 	/**
 	 * 获取部门列表

+ 32 - 1
qywechat.class.php

@@ -37,7 +37,8 @@ class Wechat
     const DEPARTMENT_CREATE_URL = '/department/create?';
     const DEPARTMENT_UPDATE_URL = '/department/update?';
     const DEPARTMENT_DELETE_URL = '/department/delete?';
-    const DEPARTMENT_LIST_URL = '/department/LIST?';
+    const DEPARTMENT_MOVE_URL = '/department/move?';
+    const DEPARTMENT_LIST_URL = '/department/list?';
     const TAG_CREATE_URL = '/tag/create?';
     const TAG_UPDATE_URL = '/tag/update?';
     const TAG_DELETE_URL = '/tag/delete?';
@@ -997,6 +998,36 @@ class Wechat
 	    }
 	    return false;
 	}
+
+	/**
+	 * 移动部门
+	 * @param $data
+	 * array(
+	 *    "department_id" => "5",	//所要移动的部门
+	 *    "to_parentid" => "2",		//想移动到的父部门节点,根部门为1
+	 *    "to_position" => "1"		//(非必须)想移动到的父部门下的位置,1表示最上方,往后位置为2,3,4,以此类推,默认为1
+	 * )
+	 * @return boolean|array 成功返回结果
+	 * {
+	 *   "errcode": 0,        //返回码
+	 *   "errmsg": "ok"  //对返回码的文本描述内容
+	 * }
+	 */
+	public function moveDepartment($data){
+	    if (!$this->access_token && !$this->checkAuth()) return false;
+	    $result = $this->http_get(self::API_URL_PREFIX.self::DEPARTMENT_MOVE_URL.'access_token='.$this->access_token,self::json_encode($data));
+	    if ($result)
+	    {
+	        $json = json_decode($result,true);
+	        if (!$json || !empty($json['errcode']) || $json['errcode']!=0) {
+	            $this->errCode = $json['errcode'];
+	            $this->errMsg = $json['errmsg'];
+	            return false;
+	        }
+	        return $json;
+	    }
+	    return false;
+	}
 	
 	/**
 	 * 获取部门列表

+ 1 - 0
wiki/企业号API类库.md

@@ -72,6 +72,7 @@ $options = array(
 * createDepartment($data) 创建部门,参数: array("name"=>"邮箱产品组","parentid"=>"1","order" =>  "1")
 * updateDepartment($data) 更新部门,参数: array("id"=>"1","name"=>"邮箱产品组","parentid"=>"1","order" =>  "1")
 * deleteDepartment($id) 删除部门,参数:要删除的部门id
+* moveDepartment($data) 移动部门,参数:array("department_id" => "5","to_parentid" => "2","to_position" => "1")
 * getDepartment() 获取部门列表,返回部门数组。其中department部门列表数据。以部门的order字段从小到大排列
 * createUser($data) 创建成员,参数请看php文件内方法说明
 * updateUser($data) 更新成员,参数请看php文件内方法说明