isOptions()) { error('OPTIONS请求'); } $response = $next($request); $token=$request->param('token'); $userinfo = Cache::get('user:info:'.$token); $data=[ 'system' =>strtolower(ltrim($request->root(),"/")), 'controller' => strtolower($request->controller()), 'action' =>strtolower($request->action()), 'param' =>json_encode($request->param(),JSON_UNESCAPED_UNICODE), 'response' =>"[]", 'client_ip'=>$request->ip(), 'action_id' => $userinfo['id']??0, 'action_name' => $userinfo['nickname']??'system' ]; $log=SystemLog::create($data); $this->logid=$log->id; return $response; } public function end(\think\Response $response) { SystemLog::where('id',$this->logid)->update(['response'=>json_encode($response->getData(),JSON_UNESCAPED_UNICODE)]); } }