1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\middleware;
- use think\facade\Db;
- class PostLog
- {
- /**
- * 处理请求
- *
- * @param \think\Request $request
- * @param \Closure $next
- * @return Response
- */
- public function handle($request, \Closure $next)
- {
- $param = $request->post();
- $rid= "";$rname= "";
- if(isset($param['token']) && $param['token']!=''){
- $apply_id = GetUserInfo($param['token']);
- if(empty($apply_id)||$apply_id['code']!=0){
- $rid= "";
- $rname= "";
- }else{
- $rid= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
- $rname= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
- }
- }
- $server = $request->server();
- $data=[
- "uri_name"=>$server['REQUEST_URI'],
- "param"=>json_encode($param,JSON_UNESCAPED_UNICODE),
- "response"=>'',
- "action_id"=>$rid,
- "action_name"=>$rname,
- "addtime"=>date("Y-m-d H:i:s")
- ] ;
- Db::name("data_log")->insert($data);
- $response = $next($request);
- return $response;
- }
- public function end($response){
- }
- }
|