<?php<web88@qq.com>
namespace app\page\controller;
use app\common\controller\Base;
use lib\ReturnCode;
use think\facade\Hook;
use app\admin\library\Auth;
class BasePageController extends Base
{
use \app\common\traits\admin\AdminCurd;
public function initialize()
{
parent::initialize();
$this->auth = new Auth($this->request->accessToken);
$this->uid = $this->auth->uid;
if (!$this->tenant_id) {
$this->tenant_id = $this->auth->tenant_id;
}
if (!$this->auth->match($this->noNeedLogin)) {
if (!$this->auth->isLogin()) {
Hook::listen('admin_nologin', $this);
$this->reError(ReturnCode::LOGIN_OUT);
}
if (!$this->auth->match($this->noNeedRight)) {
if (!$this->auth->check($this->request->pathAuth)) {
Hook::listen('admin_nopermission', $this);
$this->reError(ReturnCode::NOT_AUTH);
}
}
}
if ($this->model) {
$this->model->setConfig(['tenant_id' => $this->tenant_id, 'uid' => $this->uid]);
}
if ($this->model && $this->auth->match($this->validateAction)) {
$this->validateAuto();
}
}
}