refactor: 修改Api返回封装
This commit is contained in:
@@ -3,26 +3,26 @@
|
||||
|
||||
// 接口错误返回
|
||||
if (!function_exists('error')) {
|
||||
function error($msg = '', $data = []): \think\response\Json
|
||||
function error($msg = '', $data = [], $status_code = 200): \think\response\Json
|
||||
{
|
||||
return \apiret\Api::error($msg, $data);
|
||||
return \apiret\Api::error($msg, $data, $status_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 接口成功返回
|
||||
if (!function_exists('success')) {
|
||||
function success($msg = '', $data = []): \think\response\Json
|
||||
function success($msg = '', $data = [], $status_code = 200): \think\response\Json
|
||||
{
|
||||
return \apiret\Api::success($msg, $data);
|
||||
return \apiret\Api::success($msg, $data, $status_code);
|
||||
}
|
||||
}
|
||||
|
||||
// 接口调结果返回
|
||||
if (!function_exists('result')) {
|
||||
function result($errno, $msg = '', $data = []): \think\response\Json
|
||||
function result($errno, $msg = '', $data = [], $status_code = 200): \think\response\Json
|
||||
{
|
||||
return \apiret\Api::result($errno)->message($msg)->response($data);
|
||||
return \apiret\Api::result($errno)->message($msg)->response($data, $status_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user