1414
1515use HPlus \Admin \Facades \Admin ;
1616use HPlus \Admin \Model \Admin \OperationLog ;
17- use HPlus \Helper \RunTime ;
1817use Hyperf \Contract \ConfigInterface ;
1918use Hyperf \Utils \Str ;
2019use Psr \Http \Message \ResponseInterface ;
2120use Psr \Http \Message \ServerRequestInterface ;
2221use Psr \Http \Server \MiddlewareInterface ;
2322use Psr \Http \Server \RequestHandlerInterface ;
24- use Qbhy \HyperfAuth \Authenticatable ;
25- use Qbhy \HyperfAuth \AuthGuard ;
2623use Qbhy \HyperfAuth \AuthManager ;
27- use Qbhy \HyperfAuth \Exception \UnauthorizedException ;
2824
2925/**
3026 * Class AuthMiddleware.
@@ -33,7 +29,7 @@ class LogsMiddleware implements MiddlewareInterface
3329{
3430 protected $ config ;
3531
36- public function __construct (AuthManager $ auth , ConfigInterface $ config )
32+ public function __construct (ConfigInterface $ config )
3733 {
3834 $ this ->config = $ config ->get ('admin.operation_log ' );
3935 }
@@ -46,9 +42,9 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
4642 ) {
4743 return $ handler ->handle ($ request );
4844 }
49- $ RunTime = new RunTime ;
45+ $ time = $ this -> getMicroTime () ;
5046 $ response = $ handler ->handle ($ request );
51- $ time = $ RunTime -> spent ( );
47+ $ time = round (( $ this -> getMicroTime () - $ time ) * 1000 , 1 );
5248 try {
5349 OperationLog::create ([
5450 'user_id ' => Admin::user ()->getId (),
@@ -62,11 +58,17 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
6258 ]);
6359 } catch (\Throwable $ exception ) {
6460 // pass
65- Logger ()->info ("可能您的log日志表不是最新的, 请执行 php bin/hyperf.php admin:db -l 查看升级命令 " );
61+ Logger ()->info ("可能您的log日志表不是最新的, 请执行 php bin/hyperf.php admin:db -l 查看升级命令 " );
6662 }
6763 return $ response ;
6864 }
6965
66+ private function getMicroTime ()
67+ {
68+ list ($ usec , $ sec ) = explode (' ' , microtime ());
69+ return ((float )$ usec + (float )$ sec );
70+ }
71+
7072 /**
7173 * Whether requests using this method are allowed to be logged.
7274 *
0 commit comments