RightModel.class.php 1.54 KB
<?php

namespace Common\Model;

class RightModel extends AbstractModel
{

    /**
     * 构造方法
     */
    public function __construct()
    {
        parent::__construct();
    }


    /**
     * 获取人员有权限参与的的活动列表
     *
     * @param string $uid 用户uid
     * @param array $dpIds 用户部门(包含父部门)集合
     * @param string $jobId 用户岗位id
     * @param string $roleId 用户角色id
     * @param array $tagId 用户标签id
     *
     * @return array
     */
    public function get_right_look_activity_list($uid = '', $dpIds = [], $jobId = '', $roleId = '', $tagId = [])
    {

        // 组装查询语句
        $where = ' status<' . self::ST_DELETE . " AND domain= '" . QY_DOMAIN . "' AND r_type=0 ";

        // 如果岗位ID存在
        if (!empty($jobId)) {
            $jobId_where = " OR job_id='" . $jobId . "'";
        }

        // 如果角色ID存在
        if (!empty($roleId)) {
            $roleId_where = " OR role_id='" . $roleId . "'";
        }

        if (!empty($dpIds)) {

            $dps = implode(',', $dpIds);
            $dp_sql = " OR dp_id IN('" . $dps . "')";
        }

        if (!empty($tagId)) {

            $tags = implode(',', $tagId);
            $tag_sql = " OR tag_id IN('" . $tags . "')";
        }

        $where .= " AND  ( uid= '" . $uid . "'" . $dp_sql . $jobId_where . $roleId_where . $tag_sql . " ) ";

        $sql = "SELECT ac_id FROM __TABLE__ WHERE " . $where;

        // 读取记录
        return $this->_m->fetch_array($sql, []);
    }
}