<?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; } }