mirror of
https://github.com/v2board/v2board.git
synced 2024-11-15 00:09:13 +08:00
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Jobs;
|
||
|
|
||
|
use App\Services\ServerService;
|
||
|
use Illuminate\Bus\Queueable;
|
||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||
|
use Illuminate\Foundation\Bus\Dispatchable;
|
||
|
use Illuminate\Queue\InteractsWithQueue;
|
||
|
use Illuminate\Queue\SerializesModels;
|
||
|
|
||
|
class ServerLogJob implements ShouldQueue
|
||
|
{
|
||
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
protected $u;
|
||
|
protected $d;
|
||
|
protected $userId;
|
||
|
protected $server;
|
||
|
protected $protocol;
|
||
|
|
||
|
public $tries = 3;
|
||
|
public $timeout = 3;
|
||
|
|
||
|
/**
|
||
|
* Create a new job instance.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function __construct($u, $d, $userId, $server, $protocol)
|
||
|
{
|
||
|
$this->onQueue('server_log');
|
||
|
$this->u = $u;
|
||
|
$this->d = $d;
|
||
|
$this->userId = $userId;
|
||
|
$this->server = $server;
|
||
|
$this->protocol = $protocol;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Execute the job.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function handle()
|
||
|
{
|
||
|
$serverService = new ServerService();
|
||
|
if (!$serverService->log(
|
||
|
$this->userId,
|
||
|
$this->server->id,
|
||
|
$this->u,
|
||
|
$this->d,
|
||
|
$this->server->rate,
|
||
|
$this->protocol
|
||
|
)) {
|
||
|
throw new \Exception('日志记录失败');
|
||
|
}
|
||
|
}
|
||
|
}
|