2022-03-22 15:37:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\common\middleware;
|
|
|
|
|
2022-08-23 16:27:21 +00:00
|
|
|
use Closure;
|
2023-06-25 18:36:53 +00:00
|
|
|
use Throwable;
|
2022-03-22 15:37:38 +00:00
|
|
|
use think\facade\Config;
|
|
|
|
use app\admin\model\AdminLog as AdminLogModel;
|
|
|
|
|
|
|
|
class AdminLog
|
|
|
|
{
|
2023-06-25 18:36:53 +00:00
|
|
|
/**
|
|
|
|
* 写入管理日志
|
|
|
|
* @throws Throwable
|
|
|
|
*/
|
2022-08-23 16:27:21 +00:00
|
|
|
public function handle($request, Closure $next)
|
2022-03-22 15:37:38 +00:00
|
|
|
{
|
|
|
|
$response = $next($request);
|
2022-03-22 19:21:42 +00:00
|
|
|
if (($request->isPost() || $request->isDelete()) && Config::get('buildadmin.auto_write_admin_log')) {
|
2024-03-30 17:09:21 +00:00
|
|
|
AdminLogModel::instance()->record();
|
2022-03-22 15:37:38 +00:00
|
|
|
}
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
}
|