更新
This commit is contained in:
@@ -85,7 +85,7 @@ class Department extends Controller
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'required|string|max:50',
|
||||
'parent_id' => 'nullable|integer|exists:auth_departments,id',
|
||||
'parent_id' => 'nullable|integer',
|
||||
'leader' => 'nullable|string|max:50',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
'sort' => 'nullable|integer|min:0',
|
||||
@@ -108,7 +108,7 @@ class Department extends Controller
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'name' => 'nullable|string|max:50',
|
||||
'parent_id' => 'nullable|integer|exists:auth_departments,id',
|
||||
'parent_id' => 'nullable|integer',
|
||||
'leader' => 'nullable|string|max:50',
|
||||
'phone' => 'nullable|string|max:20',
|
||||
'sort' => 'nullable|integer|min:0',
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\System\Admin;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\LogRequest;
|
||||
use App\Services\System\LogService;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\GenericExport;
|
||||
|
||||
@@ -30,39 +31,9 @@ class Log extends Controller
|
||||
public function export(LogRequest $request)
|
||||
{
|
||||
$params = $request->validated();
|
||||
$pageSize = $params['page_size'] ?? 10000; // 导出时默认获取更多数据
|
||||
$filePath = $this->logService->export($params);
|
||||
|
||||
// 获取所有符合条件的日志(不分页)
|
||||
$query = $this->logService->getListQuery($params);
|
||||
$logs = $query->limit($pageSize)->get();
|
||||
|
||||
// 准备导出数据
|
||||
$headers = [
|
||||
'ID', '用户名', '模块', '操作', '请求方法', 'URL', 'IP地址',
|
||||
'状态码', '状态', '错误信息', '执行时间(ms)', '创建时间'
|
||||
];
|
||||
|
||||
$data = [];
|
||||
foreach ($logs as $log) {
|
||||
$data[] = [
|
||||
$log->id,
|
||||
$log->username,
|
||||
$log->module,
|
||||
$log->action,
|
||||
$log->method,
|
||||
$log->url,
|
||||
$log->ip,
|
||||
$log->status_code,
|
||||
$log->status === 'success' ? '成功' : '失败',
|
||||
$log->error_message ?? '-',
|
||||
$log->execution_time,
|
||||
$log->created_at->format('Y-m-d H:i:s'),
|
||||
];
|
||||
}
|
||||
|
||||
$filename = '系统操作日志_' . date('YmdHis') . '.xlsx';
|
||||
|
||||
return Excel::download(new GenericExport($headers, $data), $filename);
|
||||
return response()->download($filePath)->deleteFileAfterSend(true);
|
||||
}
|
||||
|
||||
public function show(int $id)
|
||||
@@ -93,7 +64,7 @@ class Log extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function batchDelete(Request $request)
|
||||
public function batchDelete(\Illuminate\Http\Request $request)
|
||||
{
|
||||
$this->logService->batchDelete($request->input('ids', []));
|
||||
return response()->json([
|
||||
|
||||
Reference in New Issue
Block a user