爬虫开发
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled

This commit is contained in:
cjd
2026-02-18 12:56:36 +08:00
parent a98bc6f13c
commit 260460df03
45 changed files with 4091 additions and 8 deletions

59
app/Models/CrawlRun.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace App\Models;
use App\Enums\CrawlRunStatus;
use App\Enums\CrawlTriggerType;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class CrawlRun extends Model
{
use HasFactory;
protected $fillable = [
'rule_id',
'trigger_type',
'status',
'started_at',
'finished_at',
'total_urls',
'success_count',
'failed_count',
'skipped_count',
'error_summary',
'metrics',
'created_by',
];
protected function casts(): array
{
return [
'trigger_type' => CrawlTriggerType::class,
'status' => CrawlRunStatus::class,
'started_at' => 'datetime',
'finished_at' => 'datetime',
'metrics' => 'array',
];
}
public function rule(): BelongsTo
{
return $this->belongsTo(CrawlRule::class, 'rule_id');
}
public function items(): HasMany
{
return $this->hasMany(CrawlRunItem::class, 'run_id');
}
public function alerts(): HasMany
{
return $this->hasMany(CrawlAlert::class, 'run_id');
}
}