| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | <?phpnamespace app\admin\controller;use think\Db;class Auth extends Base{    public $userId;    public $orgId;    public $rolesId;    protected function initialize()    {        if(!is_login()){            if(request()->isAjax()){                $this->error('未登录,请先登录');            }else{                $url = request()->domain().'/common/login.html';                $this->redirect($url);            }        }        $this->userId = is_login();        $this->orgId = cur_org_id();        $user = session('user_auth');        $this->rolesId = !empty($user)&&isset($user['rolesId'])?$user['rolesId']:0;        $this->assign('rolesId',$this->rolesId);        // 检查是否有紧急事件        $info = Db::name('burst_record')            ->where('user_id',$this->userId)            ->where('status',1)            ->where('del',0)            ->find();        if($info){            $this->redirect(url('Bursting/index'));        }        parent::initialize();    }    public function getTableField($table,$where,$field){        $val = Db::name($table)            ->where($where)            ->value($field);        return $val;    }}
 |