\addons\pickup\controllerBase

Summary

Methods
Properties
Constants
__construct()
No public properties found
No constants found
initialize()
success()
error()
result()
validate()
token()
cache()
$request
$responseType
N/A
No private methods found
No private properties found
N/A

Properties

$request

$request : \app\common\controller\Request

Type

\app\common\controller\Request — Request 实例

$responseType

$responseType : string

默认响应输出类型,支持json/xml

Type

string

Methods

__construct()

__construct(\think\App  $app) : mixed

构造方法

Parameters

\think\App $app

Returns

mixed —

initialize()

initialize() : mixed

初始化操作

Returns

mixed —

success()

success(string  $msg = '', mixed  $data = null, int  $code = 1, string  $type = null, array  $header = []) : mixed

操作成功返回的数据

Parameters

string $msg

提示信息

mixed $data

要返回的数据

int $code

错误码,默认为1

string $type

输出类型

array $header

发送的 Header 信息

Returns

mixed —

error()

error(string  $msg = '', mixed  $data = null, int  $code, string  $type = null, array  $header = []) : mixed

操作失败返回的数据

Parameters

string $msg

提示信息

mixed $data

要返回的数据

int $code

错误码,默认为0

string $type

输出类型

array $header

发送的 Header 信息

Returns

mixed —

result()

result(mixed  $msg, mixed  $data = null, int  $code, string  $type = null, array  $header = []) : void

返回封装后的 API 数据到客户端

Parameters

mixed $msg

提示信息

mixed $data

要返回的数据

int $code

错误码,默认为0

string $type

输出类型,支持json/xml/jsonp

array $header

发送的 Header 信息

Throws

\think\exception\HttpResponseException

validate()

validate(array  $data, string|array  $validate, array  $message = [], bool  $batch = false, mixed  $callback = null) : array|string|true

验证数据

Parameters

array $data

数据

string|array $validate

验证器名或者验证规则数组

array $message

提示信息

bool $batch

是否批量验证

mixed $callback

回调方法(闭包)

Throws

\think\exception\ValidateException

Returns

array|string|true —

token()

token() : mixed

Returns

mixed —

cache()

cache(mixed  $name, callable  $callback = null) : mixed

Parameters

mixed $name
callable $callback

Returns

mixed —