<?php

namespace app\extra\service\star;

use app\extra\basic\Service;
use app\model\star\StarTaskVideo;

class TaskVideoService extends Service
{


    /**
     * 列表
     * @param array $param
     */
    public function getList(array $param = [])
    {
        $this->mode = new StarTaskVideo();
        return $this->searchVal($param,$this->searchFilter($param))->with(['star' => function($query){
            $query->field("author_id,avatar_uri,show_nick_name,follower,wechat,author_level")->append(['level','nick_name'])->withAttr(['level' => function($data,$resp){
                return str_replace('"', '', $resp['author_level']);
            },'nick_name' => function($data,$resp) {
                return unicodeToEmoji($resp['show_nick_name']);
            }]);
        }])->paginate([
            "list_rows" => $param['pageSize'],
            "page"      => $param['page']
        ]);
    }

    /**
     *
     * @param array $param
     * @return array
     */
    public function searchFilter(array $param = []): array
    {
        $filter = [];
        !empty($param['type']) && $filter[] = ["type", '=', $param['type']];
        !empty($param['status']) && $filter[] = ["status", '=', $param['status']];
        !empty($param['job']) && $filter[] = ["job_id", 'like', $param['job']];
        return $filter;
    }

}