MatchmakerBaseController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +---------------------------------------------------------------------
  9. // | Author: Dean <zxxjjforever@163.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\matchmaker\controller;
  12. use app\matchmaker\model\MatchmakerModel;
  13. use cmf\controller\HomeBaseController;
  14. use think\facade\Session;
  15. class MatchmakerBaseController extends HomeBaseController
  16. {
  17. protected $matchmaker = null;
  18. public function initialize()
  19. {
  20. parent::initialize();
  21. $matchmaker_id = session('matchmaker.id');
  22. //记录回调
  23. $domain = $this->request->url(true);
  24. Session::set('domain', $domain);
  25. if (empty($matchmaker_id)) {
  26. if ($this->request->isAjax()) {
  27. $this->error("您尚未登录", cmf_url("matchmaker/Login/index"));
  28. } else {
  29. $this->redirect(cmf_url("matchmaker/Login/index"));
  30. }
  31. }
  32. $this->matchmaker = MatchmakerModel::get($matchmaker_id);
  33. if (empty($this->matchmaker)) {
  34. Session::destroy();
  35. $this->redirect(cmf_url("matchmaker/Login/index"));
  36. }
  37. }
  38. }