This commit is contained in:
molong
2022-05-24 16:10:50 +08:00
parent a37870c93b
commit d8e43f9e93
63 changed files with 2169 additions and 230 deletions

View File

@@ -10,9 +10,9 @@ declare (strict_types = 1);
namespace app\middleware;
class Api{
use app\services\auth\UsersLogService;
public $data = ['code' => 1, 'data' => '', 'message' => ''];
class Api{
/**
* 处理请求
@@ -22,22 +22,18 @@ class Api{
* @return Response
*/
public function handle($request, \Closure $next){
$request->pageConfig = array(
'list_rows' => $request->param('pageSize', 30),
'page' => $request->param('page', 1),
);
$response = $next($request);
if (is_array($response->getData())) {
$this->data = array_merge($this->data, $response->getData());
//记录用户操作记录
app()->make(UsersLogService::class)->record($request, $response->getCode());
if ($request->isAjax() || is_array($response->getData())) {
return json($response->getData());
} else {
$this->data = $response->getData();
}
if ($request->isAjax()) {
return json($this->data);
} else {
if (\is_string($this->data) && $this->data != '') {
return $response;
} else {
return json($this->data);
}
return $response;
}
}
}