12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php namespace App\Servers\WechatWork;
- /**
- * 通讯录 部门管理
- *
- */
- class Department extends Work
- {
- /**
- * 获取列表
- *
- * @param int|null $id 获取指定部门及其下的子部门,默认获取全量组织架构
- *
- */
- public function getList($id=null){
- // 获取部门列表
- $result = $this->work->department->list($id);
- // 返回列表
- if( $result['errcode'] == 0 ) return $result['department'];// [["id"=>2, "name"=>"研发部", "parentid"=>1, "order"=>100000000,"department_leader"=>["Evan","LiuLiJun"]]];
- // 如果请求失败,返回空数据
- return [];
- }
- /**
- * 获取部门详情
- *
- * @param int $id 部门ID
- *
- */
- public function getOne($id){
- // 获取部门列表
- $result = $this->work->department->get($id);
- // 返回列表
- if( $result['errcode'] == 0 ) return $result['department'];// ["id"=>2, "name"=>"研发部", "parentid"=>1, "order"=>100000000,"department_leader"=>["Evan","LiuLiJun"]]
- // 如果请求失败,返回空数据
- return [];
- }
- /**
- * 添加
- *
- * @param array $data 部门信息
- * name 部门名称 *
- * parentid 上级ID *
- * order order值大的排序靠前。有效的值范围是[0, 2^32)
- */
- public function add($data){
- // 获取部门列表
- $result = $this->work->department->create($data); // ["errcode"=>0,"errmsg=>"created","id"=>2]
- // 返回列表
- if( $result['errcode'] == 0 ) return $result['id'];
- // 如果请求失败,返回空数据
- return 0;
- }
- /**
- * 修改
- *
- * @param int $id 部门ID
- * @param array $data 部门信息
- * name 部门名称 *
- * parentid 上级ID *
- * order order值大的排序靠前。有效的值范围是[0, 2^32)
- *
- */
- public function edit($id,$data){
- // 获取部门列表
- $result = $this->work->department->update($id,$data); // ["errcode"=>0,"errmsg=>"updated"]
- // 返回列表
- if( $result['errcode'] == 0 ) return $id;
- // 如果请求失败,返回空数据
- return 0;
- }
- /**
- * 删除
- *
- * @param int $id 部门ID
- *
- */
- public function del($id){
- // 获取部门列表
- $result = $this->work->department->delete($id); // ["errcode"=>0,"errmsg=>"deleted"]
- // 返回列表
- if( $result['errcode'] == 0 ) return $id;
- // 如果请求失败,返回空数据
- return 0;
- }
- }
|