xiaoai/php_server/app/api/lists/sv/SvVideoTaskLists.php

56 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\api\lists\sv;
use app\api\lists\BaseApiDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\model\sv\SvVideoTask;
use app\common\service\FileService;
/**
* 视频任务列表
* Class SvVideoTaskLists
* @package app\api\lists\sv
*/
class SvVideoTaskLists extends BaseApiDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
'=' => [ 'type', 'status', 'video_setting_id', 'audio_type', 'model_version'],
'%like%' => ['name', 'title', 'subtitle'],
'between' => ['create_time'],
// 其他搜索条件
];
}
public function lists(): array
{
$this->searchWhere[] = ['user_id', '=', $this->userId];
$list = SvVideoTask::where($this->searchWhere)
->order(['id' => 'desc'])
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
// 处理特定字段将JSON字符串转为数组
foreach ($list as &$item) {
if (!empty($item['extra'])) {
$item['extra'] = json_decode($item['extra'], true);
} else {
$item['extra'] = [];
}
$item['audio_url'] = FileService::getFileUrl($item['audio_url']);
$item['upload_audio_url'] = FileService::getFileUrl($item['upload_audio_url']);
$item['upload_video_url'] = FileService::getFileUrl($item['upload_video_url']);
$item['video_result_url'] = FileService::getFileUrl($item['video_result_url']);
}
return $list;
}
public function count(): int
{
return SvVideoTask::where($this->searchWhere)->count();
}
}