feat: implement system-wide activity logging with database persistence, repository patterns, and admin controller access.
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Http\Services\vCenter;
|
||||
use App\Models\Order;
|
||||
use App\Models\Service;
|
||||
use App\Repositories\Api\ServiceClient\ServiceClientRepository;
|
||||
use App\Services\ActivityLogger;
|
||||
use App\Services\Api\ServiceClient\ServiceClientService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -17,13 +18,16 @@ class ServiceController extends Controller
|
||||
{
|
||||
protected $serviceClientService;
|
||||
protected $serviceClientRepository;
|
||||
protected ActivityLogger $activityLogger;
|
||||
|
||||
public function __construct(
|
||||
ServiceClientService $serviceClientService,
|
||||
ServiceClientRepository $serviceClientRepository
|
||||
ServiceClientRepository $serviceClientRepository,
|
||||
ActivityLogger $activityLogger,
|
||||
) {
|
||||
$this->serviceClientService = $serviceClientService;
|
||||
$this->serviceClientRepository = $serviceClientRepository;
|
||||
$this->activityLogger = $activityLogger;
|
||||
}
|
||||
|
||||
public function getService(Request $request)
|
||||
@@ -99,6 +103,14 @@ class ServiceController extends Controller
|
||||
|
||||
$ticket = basename(parse_url((string) $consoleTicket['data'], PHP_URL_PATH));
|
||||
|
||||
$this->activityLogger->log(
|
||||
event: 'console_access',
|
||||
logName: 'VM',
|
||||
description: "Customer {$customer->email} truy cập console VM: {$vm->name} (service: {$uuid})",
|
||||
subject: $vm,
|
||||
newValues: ['service_uuid' => $uuid, 'vm_name' => $vm->name],
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'message' => $ticket,
|
||||
@@ -154,6 +166,14 @@ class ServiceController extends Controller
|
||||
return response()->json(['error' => true, 'message' => $consoleTicket['data']]);
|
||||
}
|
||||
|
||||
$this->activityLogger->log(
|
||||
event: 'console_access',
|
||||
logName: 'VM',
|
||||
description: "Customer {$customer->email} truy cập console VM: {$vm->name} (order: {$order->order_num})",
|
||||
subject: $vm,
|
||||
newValues: ['order_num' => $order->order_num, 'vm_name' => $vm->name],
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'error' => false,
|
||||
'data' => $consoleTicket['data'],
|
||||
|
||||
Reference in New Issue
Block a user