AuthorityModel.class.php
2.35 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
84
<?php
namespace Common\Model;
class AuthorityModel extends AbstractModel
{
// 手机端可见范围 人员
const AUTHORITY_ID_TYPE_MEMBER = 1;
// 手机端可见范围 角色
const AUTHORITY_ID_TYPE_ROLE = 2;
// 手机端可见范围 岗位
const AUTHORITY_ID_TYPE_JOB = 3;
// 手机端可见范围
const AUTHORITY_ID_TYPE = [
self::AUTHORITY_ID_TYPE_MEMBER,
self::AUTHORITY_ID_TYPE_JOB,
self::AUTHORITY_ID_TYPE_ROLE,
];
// 构造方法
public function __construct()
{
parent::__construct();
}
public function getPermissionScopeWithAuthorityId($authorityId, $apIds, $rankFilter)
{
$sql = "SELECT * FROM
oa_assistant_authority AS aa LEFT JOIN oa_assistant_authority_main as am
ON aa.am_id = am.am_id
WHERE
aa.authority_id IN (?) AND
aa.status < ? AND
aa.domain = ? AND
am.status < ? AND
am.visible_range_type = ? AND
am.domain = ?";
$conds = [
$authorityId,
self::ST_DELETE,
QY_DOMAIN,
self::ST_DELETE,
$rankFilter,
QY_DOMAIN,
];
if (!empty($apIds)) {
$sql .= " AND am.ap_id IN (?)";
$conds[] = $apIds;
}
return $this->_m->fetch_array($sql, $conds);
}
/**
* 根据当前 排名筛选类型 查询权限对象
* @param $authorityId
* @param $visibleRangeType
* @return array
*/
public function listAuthorityWithVisibleRangeType($authorityId, $visibleRangeType)
{
$sql = "SELECT * FROM
oa_assistant_authority AS aa LEFT JOIN oa_assistant_authority_main AS am
ON aa.am_id = am.am_id
WHERE
aa.authority_id IN (?) AND
aa.status < ? AND
aa.domain = ? AND
am.status < ? AND
am.domain = ? AND
am.visible_range_type IN (?)";
return $this->_m->fetch_array($sql, [
$authorityId,
self::ST_DELETE,
QY_DOMAIN,
self::ST_DELETE,
QY_DOMAIN,
[$visibleRangeType, AuthorityMainModel::VISIBLE_RANGE_TYPE_DEFAULT]
]);
}
}