测试一下

<?php
namespace app\rest\controller;
use Throwable;
use think\Controller;
use think\facade\Log;
use app\common\JsonBean;
use think\facade\Request;
use think\exception\ValidateException;
use app\common\exception\QiniuException;
class Base extends Controller
{
// 网关检查开关
protected $gateway = false;
// 登录状态检查开关
protected $auth = false;
// 登录检查方法
protected $authOnly = [];
// 参数验证失败抛出异常 ValidateException
protected $failException = true;
/**
* 继承父类初始化
* @access private
*/
final protected function initialize()
{
// 判断是否需要开启网关检查
if ($this->gateway) {
$this->middleware[] = 'Gateway';
}
// 判断是否需要注册登录检查中间件
if ($this->auth) {
if (empty($this->authOnly)) {
$this->middleware[] = 'Auth';
} else {
$this->middleware['Auth'] = ['only' => $this->authOnly];
}
}
// 初始化
$this->init();
}
/**
* 自定义初始化文件供子类继承
* @access protected
* @return void
*/
protected function init()
{}
/**
* 构造验证器验证失败的返回对象
*
* @access protected
* @param ValidateException $e 异常对象
* @return \think\response\Json
*/
protected function validateFailure(ValidateException $e)
{
// 记录错误日志
Log::record($e->getError());
// 构造返回数据
$json = JsonBean::getInstance();
$json->setCode($e->getError());
return json($json);
}
/**
* 构造接口服务异常的返回对象
*
* @access protected
* @param \Throwable $e 异常对象
* @return \think\response\Json
*/
protected function serviceException(\Throwable $e)
{
// 记录错误日志
Log::record($e->getMessage());
// 构造返回数据
$json = JsonBean::getInstance();
$json->setCode('ERR_SYS_SERVICE_EXCEPTION');
return json($json);
}
/**
* 上传文件到七牛云失败
*
* @access protected
* @param QiniuException $e 异常对象
* @return \think\response\Json
*/
protected function uploadedFailure(QiniuException $e)
{
// 记录错误日志
Log::record($e->getData());
// 构造返回数据
$json = JsonBean::getInstance();
$json->setCode('ERR_LOG_UPLOADED_FAILURE');
return json($json);
}
}这是引用
标题一
标题二
下划线文字
加粗文字斜体文字