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

54 lines
1.5 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\SvVideoSetting;
/**
* 视频设置列表
* Class SvVideoSettingLists
* @package app\api\lists\sv
*/
class SvVideoSettingLists extends BaseApiDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
'=' => ['user_id', 'type', 'status'],
'%like%' => ['name'],
// 其他搜索条件
];
}
public function lists(): array
{
$this->searchWhere[] = ['user_id', '=', $this->userId];
$list = SvVideoSetting::where($this->searchWhere)
->order(['id' => 'desc'])
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
// 处理特定字段将JSON字符串转为数组
foreach ($list as &$item) {
// 转换6个特定字段为数组
$jsonFields = ['anchor', 'voice', 'title', 'subtitle', 'copywriting', 'topic','extra'];
foreach ($jsonFields as $field) {
if (!empty($item[$field])) {
$item[$field] = json_decode($item[$field], true);
} else {
$item[$field] = [];
}
}
}
return $list;
}
public function count(): int
{
return SvVideoSetting::where($this->searchWhere)->count();
}
}