增加分页响应
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace catcher;
|
namespace catcher;
|
||||||
|
|
||||||
|
use think\Paginator;
|
||||||
|
|
||||||
class CatchResponse
|
class CatchResponse
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +14,7 @@ class CatchResponse
|
|||||||
* @param int $code
|
* @param int $code
|
||||||
* @return \think\response\Json
|
* @return \think\response\Json
|
||||||
*/
|
*/
|
||||||
public static function success($data = [], $msg = '', $code = 10000): \think\response\Json
|
public static function success($data = [], $msg = 'success', $code = 10000): \think\response\Json
|
||||||
{
|
{
|
||||||
return json([
|
return json([
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
@@ -21,6 +23,24 @@ class CatchResponse
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @time 2019年12月06日
|
||||||
|
* @param Paginator $list
|
||||||
|
* @return \think\response\Json
|
||||||
|
*/
|
||||||
|
public static function paginate(Paginator $list): \think\response\Json
|
||||||
|
{
|
||||||
|
return json([
|
||||||
|
'code' => 10000,
|
||||||
|
'msg' => 'success',
|
||||||
|
'count' => $list->total(),
|
||||||
|
'current' => $list->currentPage(),
|
||||||
|
'data' => $list->getCollection(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误的响应
|
* 错误的响应
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user