<?php<web88@qq.com>
namespace app\oss\controller;
use app\common\controller\Base;
use lib\ReturnCode;
use think\facade\Hook;
use app\admin\library\Auth;
class BaseOssController extends Base
{
    protected $tenant_id=9;
    
    use \app\common\traits\admin\AdminCurd;
    public function initialize() {
        parent::initialize();
        $modulename = $this->request->module();
        $controllername = strtolower($this->request->controller());
        $actionname = strtolower($this->request->action());
        $path = str_replace('.', '/', $controllername) . '/' . $actionname;
        $this->auth = Auth::instance($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($path)) {
                    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->auth->match($this->validateAction)){
            $this->validateAuto();
        }
               Hook::exec('app\\common\\behavior\\SetConfig','');
    }
}