<?php

namespace app\controller;

use app\service\Redis;
use think\response\View;

/**
 * 控制器基础类
 */
class Base extends BaseController
{
    //需要向模板传递的值
    protected $data = [];
    //系统配置信息
    protected $system = [];

    protected $auth = [];

    protected $authId = 0;

    protected $redis = null;

    // 初始化
    protected function initialize()
    {
        $this->middleware = [
            'login' => ['except' => $this->noNeedLogin],
        ];

        $this->auth         = session('frontend_auth') ?? [];
        $this->data['auth'] = $this->auth;
        $this->authId       = $this->auth['id'] ?? 0;
        $this->redis        = Redis::instance();
    }

    //模板
    protected function view($template = ''): View
    {
        return view($template)->assign($this->data);
    }
}
