DepartmentMemberController.class.php
2.37 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/18
* Time: 11:50
*/
namespace Api\Controller\User;
use Common\Service\UserService;
class DepartmentMemberController extends AbstractController
{
/**
* 【通讯录】人员列表
* @author liyifei
* @time 2016-09-18 11:58:28
*/
public function Index_post()
{
// 接收参数并验证
$dpId = I('post.department_id', '', 'trim');
$keyword = I('post.keyword', '', 'trim');
$index = I('post.first_letter', '', 'trim');
$page = I('post.page', 1, 'intval');
$limit = I('post.limit', 30, 'intval');
// 登录用户信息
$user = $this->_login->user;
// 获取缓存用户列表信息
$userService = new UserService();
$this->checkCurrentManagePower($user);
// 读取用户有权限查看的部门列表
list(, , $childIds,) = $userService->getUserTopDpId($user);
if (empty($childIds) || !in_array($dpId, $childIds)) {
E('1009:您的权限已变更或该部门信息已更新');
return false;
}
$condition = [
'uid' => $user['memUid'],
'dpId' => $dpId,
'keyword' => $keyword,
'index' => $index,
'departmentChildrenFlag' => empty($keyword) ? 0 : 1
];
$userList = $userService->getListByConds($condition, $page, $limit);
// 当$userList中设置memUsername时,即认为返回的$userList为单个用户的详情
if (isset($userList['memUid'])) {
$result = [
'page' => $page,
'limit' => $limit,
'total' => 1,
'list' => [
'key' => '',
'valuelist' => [
'uid' => $userList['memUid'],
'username' => $userList['memUsername'],
'face' => $userList['memFace'],
'title' => $userList['memJob'],
]
],
];
} else {
$result = [
'page' => $userList['pageNum'],
'limit' => $userList['pageSize'],
'total' => $userList['total'],
'list' => $userList['list']
];
}
$this->_result = $result;
return true;
}
}