58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\lists\match;
|
|
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\common\model\match\MatchLive;
|
|
|
|
class MatchLiveLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['match_id', 'fetch_status', 'play_type', 'source_is_hot'],
|
|
'%like%' => ['title', 'source_url', 'source_site', 'source_domain'],
|
|
];
|
|
}
|
|
|
|
public function lists(): array
|
|
{
|
|
$lists = $this->buildQuery()
|
|
->field('id,match_id,title,source_url,play_type,iframe_url,source_site,source_domain,source_match_key,source_line_key,source_is_hot,source_match_time,play_url_m3u8,play_url_hd_m3u8,play_url_flv,play_url_hd_flv,fetch_status,fetch_error,last_fetch_at,next_fetch_at,create_time,update_time')
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->order('create_time', 'desc')
|
|
->order('id', 'desc')
|
|
->select()
|
|
->toArray();
|
|
|
|
foreach ($lists as &$item) {
|
|
$item['fetch_status_text'] = self::formatFetchStatus((int) ($item['fetch_status'] ?? 0));
|
|
}
|
|
unset($item);
|
|
|
|
return $lists;
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
return $this->buildQuery()->count();
|
|
}
|
|
|
|
public static function formatFetchStatus(int $status): string
|
|
{
|
|
return match ($status) {
|
|
0 => '待抓取',
|
|
1 => '抓取成功',
|
|
2 => '抓取失败',
|
|
default => '未知',
|
|
};
|
|
}
|
|
|
|
protected function buildQuery()
|
|
{
|
|
return MatchLive::whereNull('delete_time')
|
|
->where($this->searchWhere);
|
|
}
|
|
}
|