2018-12-28 18:58:37 +08:00
|
|
|
<?php
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
|
|
|
// +----------------------------------------------------------------------
|
2019-02-18 13:52:07 +08:00
|
|
|
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
2018-12-28 18:58:37 +08:00
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Author: Devil
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
|
|
use think\Controller;
|
2019-03-18 13:52:52 +08:00
|
|
|
use app\service\SystemService;
|
2019-01-17 00:37:20 +08:00
|
|
|
use app\service\ConfigService;
|
|
|
|
use app\service\UserService;
|
2018-12-28 18:58:37 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 接口公共控制器
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 0.0.1
|
|
|
|
* @datetime 2016-12-01T21:51:08+0800
|
|
|
|
*/
|
|
|
|
class Common extends Controller
|
|
|
|
{
|
|
|
|
// 用户信息
|
|
|
|
protected $user;
|
|
|
|
|
2020-06-07 17:36:43 +08:00
|
|
|
// 输入参数 post|get|request
|
2018-12-28 18:58:37 +08:00
|
|
|
protected $data_post;
|
|
|
|
protected $data_get;
|
|
|
|
protected $data_request;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 构造方法
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2018-11-30
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
// 输入参数
|
|
|
|
$this->data_post = input('post.');
|
|
|
|
$this->data_get = input('get.');
|
|
|
|
$this->data_request = input();
|
|
|
|
|
2020-06-07 17:36:43 +08:00
|
|
|
// 系统运行开始
|
|
|
|
SystemService::SystemBegin();
|
|
|
|
|
2018-12-28 18:58:37 +08:00
|
|
|
// 系统初始化
|
|
|
|
$this->SystemInit();
|
|
|
|
|
|
|
|
// 网站状态
|
|
|
|
$this->SiteStstusCheck();
|
|
|
|
|
|
|
|
// 公共数据初始化
|
|
|
|
$this->CommonInit();
|
2019-01-15 12:39:57 +08:00
|
|
|
}
|
2018-12-28 18:58:37 +08:00
|
|
|
|
2019-03-18 13:52:52 +08:00
|
|
|
/**
|
|
|
|
* 析构函数
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2019-03-18
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function __destruct()
|
|
|
|
{
|
|
|
|
// 系统运行结束
|
|
|
|
SystemService::SystemEnd();
|
|
|
|
}
|
|
|
|
|
2018-12-28 18:58:37 +08:00
|
|
|
/**
|
|
|
|
* 系统初始化
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2018-12-07
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
private function SystemInit()
|
|
|
|
{
|
|
|
|
// 配置信息初始化
|
|
|
|
ConfigService::ConfigInit();
|
|
|
|
|
|
|
|
// url模式,后端采用兼容模式
|
2019-01-11 17:35:35 +08:00
|
|
|
\think\facade\Url::root(__MY_ROOT_PUBLIC__.'index.php?s=');
|
2018-12-28 18:58:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* [SiteStstusCheck 网站状态]
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @datetime 2018-04-18T16:20:58+0800
|
|
|
|
*/
|
|
|
|
private function SiteStstusCheck()
|
|
|
|
{
|
|
|
|
if(MyC('home_site_state') != 1)
|
|
|
|
{
|
2020-01-16 15:01:30 +08:00
|
|
|
exit(json_encode(DataReturn(MyC('home_site_close_reason', '网站维护中...'), -10000)));
|
2018-12-28 18:58:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-03-02 23:17:30 +08:00
|
|
|
* [IsLogin 登录校验]
|
2018-12-28 18:58:37 +08:00
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 0.0.1
|
|
|
|
* @datetime 2017-03-09T11:43:48+0800
|
|
|
|
*/
|
2019-03-02 23:17:30 +08:00
|
|
|
protected function IsLogin()
|
2018-12-28 18:58:37 +08:00
|
|
|
{
|
|
|
|
if(empty($this->user))
|
|
|
|
{
|
2019-06-23 00:32:44 +08:00
|
|
|
exit(json_encode(DataReturn('登录失效,请重新登录', -400)));
|
2018-12-28 18:58:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* [CommonInit 公共数据初始化]
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 0.0.1
|
|
|
|
* @datetime 2017-03-09T11:43:48+0800
|
|
|
|
*/
|
|
|
|
private function CommonInit()
|
|
|
|
{
|
|
|
|
// 用户数据
|
2019-02-27 10:17:33 +08:00
|
|
|
$this->user = UserService::LoginUserInfo();
|
2018-12-28 18:58:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* [_empty 空方法操作]
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 0.0.1
|
|
|
|
* @datetime 2017-02-25T15:47:50+0800
|
|
|
|
* @param [string] $name [方法名称]
|
|
|
|
*/
|
|
|
|
protected function _empty($name)
|
|
|
|
{
|
|
|
|
exit(json_encode(DataReturn($name.' 非法访问', -1000)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|