<?php
/**
 *
 * @file:CommonController.php
 * @Date: 2023/7/6
 * @Time: 18:05
 */


namespace Modules\WechatPlatform\Http\Controllers;

use Catch\Base\CatchController;
use Catch\Exceptions\FailedException;
use Illuminate\Support\Facades\DB;
use Modules\WechatPlatform\Http\Requests\PlayPageUrlRequest;
use Modules\WechatPlatform\Services\WechatCommonService;

class CommonController extends CatchController
{

    public function getPlayPageUrl(PlayPageUrlRequest $request)
    {
        $sequence = $request->input('sequence');
        $videoId = $request->input('video_id');
        $sequenceId = DB::table('video_series')->where('video_id',$videoId)->where('series_sequence',$sequence)->where('is_enabled',1)->value('id');
        if(empty($sequenceId)){
            throw  new  FailedException("所选剧集不存在");
        }
        return WechatCommonService::getPlayPageUrl($videoId,$sequence);
    }
}
