RightModel.class.php
1.05 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
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 18/4/25
* Time: 15:29
*/
namespace Common\Model;
class RightModel extends AbstractModel
{
/**
* 构造方法
*/
public function __construct()
{
parent::__construct();
}
/**
* 根据权限数据构建查询条件
* @author zhonglei
* @param array $rights 权限数据
* @return array
*/
public function buildConds($rights)
{
$conds = [];
if (!\is_array($rights) || empty($rights)) {
return $conds;
}
foreach ($rights as $k => $v) {
switch ($k) {
// 全公司
case Constant::RIGHT_TYPE_ALL:
$conds[] = "`obj_type` = {$k}";
break;
// 部门、标签、人员、职位、角色
default:
$obj_id = implode("','", $v);
$conds[] = "(`obj_type` = {$k} and `obj_id` in ('{$obj_id}'))";
}
}
return $conds;
}
}