增加分页响应
This commit is contained in:
parent
5c7765c97f
commit
fa4837487b
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace catcher;
|
||||
|
||||
use think\Paginator;
|
||||
|
||||
class CatchResponse
|
||||
{
|
||||
/**
|
||||
@ -12,7 +14,7 @@ class CatchResponse
|
||||
* @param int $code
|
||||
* @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([
|
||||
'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(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误的响应
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user