DepartmentsController.class.php
1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* 获取用户所在部门及其子部门.
*
* @auther zs_anything
* @date 2017/08/03
*/
namespace Api\Controller\Integral;
use Common\Common\Department;
use Common\Model\PluginModel;
class DepartmentsController extends AbstractController
{
public function Index()
{
$this->checkAuthRange(PluginModel::INTEGRAL_CENTER);
$memUid = $this->_login->user['memUid'];
$deptUtil = new Department();
// 根据用户id获取当前部门
$myDpIds = $deptUtil->list_dpId_by_uid($memUid);
// 所有部门及子部门
$dpIds = $deptUtil->list_childrens_by_cdid($myDpIds, true);
// 获取部门id及部门名称
$depts = $deptUtil->listById($dpIds, array('dpId', 'dpName'));
// 根据部门排序字段、部门等级来升序排序
array_multisort(array_column($depts, 'dpLevel'), SORT_ASC,
array_column($depts, 'dpDisplayorder'), SORT_ASC, $depts);
$this->_result = array_values($depts);
return true;
}
}