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; } }