<?php

namespace App\Services;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class DeleteLogService
{
    public function logDeletion($tableName, $recordId, $name, $idCardNum, $operatorId, $operatorName, $reason, $currentOrgName, $type, $screenshot)
    {
        try {
            DB::table('delete_operation_log')->insert([
                'table_name' => $tableName,
                'record_id' => $recordId,
                'name' => $name,
                'id_card_num' => $idCardNum,
                'operator_id' => $operatorId,
                'operator_name' => $operatorName,
                'reason' => $reason,
                'current_org_name' => $currentOrgName,
                'type' => $type,
                'screenshot' => $screenshot,
                'created_at' => date('Y-m-d H:i:s'),
                'updated_at' => date('Y-m-d H:i:s'),
            ]);
        } catch (\Exception $e) {
            Log::error('删除操作日志写入失败: ' . $e->getMessage());
        }
    }
}
