2018-12-28 18:58:37 +08:00
|
|
|
<?php
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
|
|
|
// +----------------------------------------------------------------------
|
2021-03-16 10:34:52 +08:00
|
|
|
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
|
2018-12-28 18:58:37 +08:00
|
|
|
// +----------------------------------------------------------------------
|
2021-03-16 10:34:52 +08:00
|
|
|
// | Licensed ( https://opensource.org/licenses/mit-license.php )
|
2018-12-28 18:58:37 +08:00
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Author: Devil
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
2021-07-18 23:42:10 +08:00
|
|
|
use app\BaseController;
|
2021-07-20 23:45:54 +08:00
|
|
|
use app\service\ApiService;
|
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;
|
2020-12-07 18:51:13 +08:00
|
|
|
use app\module\FormHandleModule;
|
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
|
|
|
|
*/
|
2021-07-18 23:42:10 +08:00
|
|
|
class Common extends BaseController
|
2018-12-28 18:58:37 +08:00
|
|
|
{
|
|
|
|
// 用户信息
|
|
|
|
protected $user;
|
|
|
|
|
2020-12-07 18:51:13 +08:00
|
|
|
// 当前操作名称
|
|
|
|
protected $module_name;
|
|
|
|
protected $controller_name;
|
|
|
|
protected $action_name;
|
|
|
|
|
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;
|
|
|
|
|
2020-12-07 18:51:13 +08:00
|
|
|
// 分页信息
|
|
|
|
protected $page;
|
|
|
|
protected $page_size;
|
|
|
|
|
|
|
|
// 动态表格
|
|
|
|
protected $form_table;
|
|
|
|
protected $form_where;
|
|
|
|
protected $form_params;
|
|
|
|
protected $form_md5_key;
|
|
|
|
protected $form_user_fields;
|
|
|
|
protected $form_order_by;
|
|
|
|
protected $form_error;
|
|
|
|
|
2018-12-28 18:58:37 +08:00
|
|
|
/**
|
|
|
|
* 构造方法
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2018-11-30
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2021-07-18 23:42:10 +08:00
|
|
|
// 检测是否是新安装
|
|
|
|
SystemService::SystemInstallCheck();
|
2018-12-28 18:58:37 +08:00
|
|
|
|
|
|
|
// 输入参数
|
|
|
|
$this->data_post = input('post.');
|
|
|
|
$this->data_get = input('get.');
|
|
|
|
$this->data_request = input();
|
|
|
|
|
2020-06-07 17:36:43 +08:00
|
|
|
// 系统运行开始
|
2020-09-23 16:03:14 +08:00
|
|
|
SystemService::SystemBegin($this->data_request);
|
2020-06-07 17:36:43 +08:00
|
|
|
|
2018-12-28 18:58:37 +08:00
|
|
|
// 系统初始化
|
|
|
|
$this->SystemInit();
|
|
|
|
|
|
|
|
// 网站状态
|
|
|
|
$this->SiteStstusCheck();
|
|
|
|
|
2020-12-07 18:51:13 +08:00
|
|
|
// 动态表格初始化
|
|
|
|
$this->FormTableInit();
|
|
|
|
|
2018-12-28 18:58:37 +08:00
|
|
|
// 公共数据初始化
|
|
|
|
$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()
|
|
|
|
{
|
|
|
|
// 系统运行结束
|
2020-09-23 16:03:14 +08:00
|
|
|
SystemService::SystemEnd($this->data_request);
|
2019-03-18 13:52:52 +08:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-07 18:51:13 +08:00
|
|
|
* 网站状态
|
2018-12-28 18:58:37 +08:00
|
|
|
* @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)
|
|
|
|
{
|
2021-12-08 15:11:31 +08:00
|
|
|
exit(json_encode(DataReturn(MyC('home_site_close_reason', '升级中...'), -10000)));
|
2018-12-28 18:58:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-07 18:51:13 +08:00
|
|
|
* 登录校验
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-07 18:51:13 +08:00
|
|
|
/**
|
|
|
|
* 动态表格初始化
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2020-06-02
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function FormTableInit()
|
|
|
|
{
|
|
|
|
// 获取表格模型
|
|
|
|
$module = FormModulePath($this->data_request);
|
|
|
|
if(!empty($module))
|
|
|
|
{
|
|
|
|
// 调用表格处理
|
|
|
|
$params = $this->data_request;
|
|
|
|
$ret = (new FormHandleModule())->Run($module['module'], $module['action'], $params);
|
|
|
|
if($ret['code'] == 0)
|
|
|
|
{
|
|
|
|
$this->form_table = $ret['data']['table'];
|
|
|
|
$this->form_where = $ret['data']['where'];
|
|
|
|
$this->form_params = $ret['data']['params'];
|
|
|
|
$this->form_md5_key = $ret['data']['md5_key'];
|
|
|
|
$this->form_user_fields = $ret['data']['user_fields'];
|
|
|
|
$this->form_order_by = $ret['data']['order_by'];
|
|
|
|
} else {
|
|
|
|
$this->form_error = $ret['msg'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-28 18:58:37 +08:00
|
|
|
/**
|
2020-12-07 18:51:13 +08:00
|
|
|
* 公共数据初始化
|
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
|
|
|
|
*/
|
|
|
|
private function CommonInit()
|
|
|
|
{
|
|
|
|
// 用户数据
|
2019-02-27 10:17:33 +08:00
|
|
|
$this->user = UserService::LoginUserInfo();
|
2020-12-07 18:51:13 +08:00
|
|
|
|
|
|
|
// 当前操作名称
|
2021-07-18 23:42:10 +08:00
|
|
|
$this->module_name = RequestModule();
|
|
|
|
$this->controller_name = RequestController();
|
|
|
|
$this->action_name = RequestAction();
|
2020-12-07 18:51:13 +08:00
|
|
|
|
|
|
|
// 分页信息
|
|
|
|
$this->page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1);
|
|
|
|
$this->page_size = 10;
|
2018-12-28 18:58:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-18 23:42:10 +08:00
|
|
|
* 空方法响应
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2018-11-30
|
|
|
|
* @desc description
|
|
|
|
* @param [string] $method [方法名称]
|
|
|
|
* @param [array] $args [参数]
|
|
|
|
*/
|
|
|
|
public function __call($method, $args)
|
|
|
|
{
|
2021-07-20 23:45:54 +08:00
|
|
|
return ApiService::ApiDataReturn(DataReturn($method.' 非法访问', -1000));
|
2021-07-18 23:42:10 +08:00
|
|
|
}
|
2018-12-28 18:58:37 +08:00
|
|
|
}
|
|
|
|
?>
|