\laytp\controllerApi

Api应用控制器基类

Summary

Methods
Properties
Constants
success()
error()
exceptionError()
__construct()
No public properties found
No constants found
initialize()
_initialize()
$request
$app
$middleware
$noNeedLogin
$noNeedCheckSign
N/A
No private methods found
No private properties found
N/A

Properties

$request

$request : \think\Request

Request实例

Type

\think\Request

$app

$app : \think\App

应用实例

Type

\think\App

$middleware

$middleware : array

中间件

Type

array

$noNeedLogin

$noNeedLogin : array

无需登录的方法,同时也就不需要鉴权了

Type

array

$noNeedCheckSign

$noNeedCheckSign : array

无需验证签名的方法

Type

array

Methods

success()

success(string  $msg = '', null  $data = null) : false|string|\think\response\Json

操作成功返回数据

Parameters

string $msg
null $data

Returns

false|string|\think\response\Json

error()

error(string  $msg = '', integer  $code = 1, array  $data = null) : \think\response\Json

操作失败返回数据

Parameters

string $msg
integer $code

错误码,为0表示没有错误,为1表示常规错误,前端仅需提示msg,其他值有具体含义,比如10401为未登录,前端需要跳转至登录界面

array $data

Returns

\think\response\Json

exceptionError()

exceptionError(  $e) : \think\response\Json

捕获异常后返回数据

Parameters

$e

Returns

\think\response\Json

__construct()

__construct(\think\App  $app) 

构造方法

Parameters

\think\App $app

应用对象

initialize()

initialize() 

_initialize()

_initialize()