<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +---------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace app\matchmaker\controller;

use app\matchmaker\model\MatchmakerModel;
use cmf\controller\HomeBaseController;
use think\facade\Session;

class MatchmakerBaseController extends HomeBaseController
{
    protected $matchmaker = null;

    public function initialize()
    {
        parent::initialize();
        $matchmaker_id = session('matchmaker.id');

        //记录回调
        $domain = $this->request->url(true);
        Session::set('domain', $domain);

        if (empty($matchmaker_id)) {
            if ($this->request->isAjax()) {
                $this->error("您尚未登录", cmf_url("matchmaker/Login/index"));
            } else {
                $this->redirect(cmf_url("matchmaker/Login/index"));
            }
        }

        $this->matchmaker = MatchmakerModel::get($matchmaker_id);
        if (empty($this->matchmaker)) {
            Session::destroy();
            $this->redirect(cmf_url("matchmaker/Login/index"));
        }
    }
}