InfoController.class.php
1.82 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
<?php
/**
* 管理员角色详情获取
* InfoController.class.php
*
*/
namespace Apicp\Controller\AdminRole;
use VcySDK\Adminer;
use Common\Common\Department;
class InfoController extends AbstractController
{
public function Index()
{
// 当前管理员为分级管理时,无权操作
$user = $this->_login->user;
if (!isset($user['eaLevel'])) {
E('_ERR_ADMIN_MANAGER_EALEVEL_UNDEFINED');
}
if ($user['eaLevel'] == Adminer::ADMIN_LEVEL_BRANCH) {
E('_ERR_ADMIN_BRANCH_CANNOT_OPERATE');
}
// 接收数据
$earId = I('post.earId'); // 管理员角色id
// 管理员角色ID非空验证
if (empty($earId)) {
$this->_set_error('_ERR_ADMIN_ROLE_ID_EMPTY');
return false;
}
// 拼接接口所需数据:管理员角色id
$condition = array(
'earId' => $earId
);
// 调用UC接口,查询管理员详情
try {
$this->_result = $this->_sdkRole->detail($condition);
} catch (\Exception $e) {
$this->_result = [];
}
$dp_ids = array_unique(array_merge($this->_result['readDpIdList'], $this->_result['writeDpIdList']));
$dp_list = [];
// 取部门名称
if (!empty($dp_ids)) {
$dpServ = &Department::instance(true, true);
$dps = $dpServ->listById($dp_ids);
foreach ($dps as $dp) {
$dp_list[] = [
'dp_id' => $dp['dpId'],
'dp_name' => $dp['dpName'],
];
}
}
$this->_result['dp_list'] = $dp_list;
if (! $this->_result) {
$this->_set_error("_ERR_ADMIN_ROLE_NOT_EXIST");
return false;
}
return true;
}
}