AiVideoController.php 4.2 KB
<?php
/**
 * @remark :
 * @name   :AiVideoController.php
 * @author :lyh
 * @method :post
 * @time   :2025/3/5 11:00
 */

namespace App\Http\Controllers\Bside\Ai;

use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\Ai\AiVideoLogic;
use App\Models\Ai\AiVideo;
use App\Models\Ai\AiVideoList;

class AiVideoController extends BaseController
{
    /**
     * @remark :获取aiVideo列表
     * @name   :lists
     * @author :lyh
     * @method :post
     * @time   :2025/3/5 14:12
     */
    public function lists(AiVideo $aiVideo){
        $lists = $aiVideo->lists($this->map,$this->page,$this->row,'id',['id','title','route','video_url','image','task_id','status','created_at','updated_at']);
        if(!empty($lists) && !empty($lists['list'])){
            foreach ($lists['list'] as $k => $v){
                $v['image'] = getImageUrl($v['image']);
                if(!empty($v['route'])){
                    $v['route'] = $this->user['test_domain'] . 'video/' . $v['route'];
                }
                $lists['list'][$k] = $v;
            }
        }
        $this->response('success',Code::SUCCESS,$lists);
    }

    /**
     * @remark :获取详情
     * @name   :getInfo
     * @author :lyh
     * @method :post
     * @time   :2025/3/5 14:22
     */
    public function getInfo(AiVideo $aiVideo){
        $this->request->validate([
            'id'=>['required'],
        ],[
            'id.required' => '主键不能为空',
        ]);
        $info = $aiVideo->read(['id'=>$this->param['id']]);
        $this->response('success',Code::SUCCESS,$info);
    }

    /**
     * @remark :发布任务
     * @name   :sendTask
     * @author :lyh
     * @method :post
     * @time   :2025/3/5 14:29
     */
    public function sendTask(AiVideoLogic $aiVideoLogic){
        $this->request->validate([
            'title'=>['required'],
            'description'=>['required'],
            'images'=>['required'],
        ],[
            'title.required' => '标题不能为空',
            'description.required' => '短描述不能为空',
            'images.required' => '图片集合不能为空',
        ]);
        $result = $aiVideoLogic->sendTask();
        $this->response('success',Code::SUCCESS,$result);
    }

    /**
     * @remark :更新任务
     * @name   :save
     * @author :lyh
     * @method :post
     * @time   :2025/3/6 10:51
     */
    public function save(AiVideoLogic $aiVideoLogic){
        $this->request->validate([
            'id'=>['required'],
        ],[
            'id.required' => '关键字不能为空',
        ]);
        $aiVideoLogic->videoSave();
        $this->response('success');
    }

    /**
     * @remark :删除ai视频
     * @name   :delete
     * @author :lyh
     * @method :post
     * @time   :2025/3/6 9:56
     */
    public function delete(AiVideoLogic $aiVideoLogic)
    {
        $this->request->validate([
            'ids'=>['required'],
        ],[
            'ids.required' => 'ID不能为空'
        ]);
        $result = $aiVideoLogic->videoDelete();
        $this->response('success',Code::SUCCESS,$result);
    }


    /**
     * @remark :获取列表页数据
     * @name   :getAiBlogList
     * @author :lyh
     * @method :post
     * @time   :2025/2/21 16:22
     */
    public function getAiVideoList(AiVideoList $aiVideoList){
        $lists = $aiVideoList->lists($this->map,$this->page,$this->row,'id',['id','route','created_at','updated_at']);
        if(!empty($lists) && !empty($lists['list'])){
            foreach ($lists['list'] as $k => $v){
                $v['route'] = $this->user['domain'] . 'top-video/' . (($v['route'] > 1) ? $v['route'] : '');
                $lists['list'][$k] = $v;
            }
        }
        $this->response('success',Code::SUCCESS,$lists);
    }

    /**
     * @remark :获取列表页数据详情
     * @name   :getAiBlogListInfo
     * @author :lyh
     * @method :post
     * @time   :2025/2/21 16:26
     */
    public function getAiBlogListInfo(AiVideoList $aiVideoList){
        $this->request->validate([
            'id'=>['required'],
        ],[
            'id.required' => '主键不能为空',
        ]);
        $info = $aiVideoList->read($this->map);
        $this->response('success',Code::SUCCESS,$info);
    }
}