开打时间批量修复功能
This commit is contained in:
parent
2283f91b3f
commit
eff07c4f72
@ -6,6 +6,7 @@ use App\Models\Programs;
|
||||
use App\Models\ProgramVideos;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class ProgramVideoConstructController extends BaseController
|
||||
@ -98,4 +99,57 @@ class ProgramVideoConstructController extends BaseController
|
||||
"program"=>$program_video->program_id
|
||||
]));
|
||||
}
|
||||
|
||||
public function to_fix_created_at(Request $request, ProgramVideos $program_video) {
|
||||
if ($program_video->created_at === null) {
|
||||
return back()->withErrors([
|
||||
"id" => "没有开始时间,请先保存对应时间"
|
||||
]);
|
||||
}
|
||||
return view("program.construct.video.time_fix", [
|
||||
"program_video" => $program_video
|
||||
]);
|
||||
}
|
||||
|
||||
public function fix_created_at_base_on(Request $request, ProgramVideos $program_video)
|
||||
{
|
||||
$request->validate([
|
||||
"each_time" => ["required", "date_format:H:i:s"]
|
||||
]);
|
||||
if ($program_video->created_at === null) {
|
||||
return back()->withErrors([
|
||||
"id" => "没有开始时间,请先保存对应时间"
|
||||
]);
|
||||
}
|
||||
$each_time = $request->post("each_time");
|
||||
$each_time_sec = Carbon::createFromFormat("H:i:s", $each_time)->secondsSinceMidnight();
|
||||
/**
|
||||
* @var $program_videos ProgramVideos[]
|
||||
*/
|
||||
$program_videos = ProgramVideos::query()
|
||||
->where("video_bvid", "=", $program_video->video_bvid)
|
||||
->where("id", "!=", $program_video->id)
|
||||
->where(function ($query) use ($program_video) {
|
||||
$query->where("created_at", ">", $program_video->created_at)->orWhere("created_at", "=", null);
|
||||
})
|
||||
->get();
|
||||
/**
|
||||
* @var $created_at Carbon
|
||||
*/
|
||||
$created_at = $program_video->created_at;
|
||||
$base_time = $created_at->subSeconds($program_video->start_sec)->subSeconds(($program_video->start_part - 1) * $each_time_sec);
|
||||
foreach ($program_videos as $video) {
|
||||
if ($video->id === $program_video->id) {
|
||||
continue;
|
||||
}
|
||||
$time = $base_time->copy()->addSeconds(($video->start_part - 1) * $each_time_sec)->addSeconds($video->start_sec);
|
||||
if ($time->second > 30) {
|
||||
$time->addMinute();
|
||||
}
|
||||
$time->seconds(0);
|
||||
$video->created_at = $time;
|
||||
$video->update();
|
||||
}
|
||||
return redirect(route("program.construct.list"));
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,9 @@
|
||||
href="https://www.bilibili.com/video/{{$program_video->video_bvid}}?p={{$program_video->stop_part}}&t={{$program_video->stop_sec}}"
|
||||
title="P{{$program_video->stop_part}}#{{$program_video->stop_time}}"
|
||||
>打开至结束位置</a>
|
||||
<a class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white"
|
||||
href="{{ url(route("program.construct.video.batch_fix_created_at", ["program_video" => $program_video->id])) }}"
|
||||
>去批量修复开打时间</a>
|
||||
</div>
|
||||
@endif
|
||||
</form>
|
||||
|
40
resources/views/program/construct/video/time_fix.blade.php
Normal file
40
resources/views/program/construct/video/time_fix.blade.php
Normal file
@ -0,0 +1,40 @@
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>录播节目关联视频位置修改</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link href="{{ mix('/css/app.css') }}" rel="stylesheet"/>
|
||||
</head>
|
||||
<body>
|
||||
@include("common.header")
|
||||
<form class="w-full lg:w-1/2 lg:ml-6 border-2" action="" method="post" enctype="multipart/form-data">
|
||||
<div class="text-lg font-bold">时间基准信息</div>
|
||||
<input type="hidden" name="id" value="{{$program_video->id}}">
|
||||
<label class="block my-2">
|
||||
BVID
|
||||
<input class="form-input border-0 border-b-2 w-full" disabled type="text" name="video_bvid" value="{{ $program_video->video_bvid }}">
|
||||
</label>
|
||||
<label class="block my-2">
|
||||
开始P数
|
||||
<input class="form-input border-0 border-b-2 w-full" disabled type="number" name="start_part" value="{{ $program_video->start_part }}">
|
||||
</label>
|
||||
<label class="block my-2">
|
||||
开始时间
|
||||
<input class="form-input border-0 border-b-2 w-full" disabled step="1" type="time" name="start_time" value="{{ $program_video->start_time }}">
|
||||
</label>
|
||||
<label class="block my-2">
|
||||
节目开打时间
|
||||
<input class="form-input border-0 border-b-2 w-full" disabled type="datetime-local" step="1" name="created_at" value="{{ $program_video->created_at }}">
|
||||
</label>
|
||||
<label class="block my-2">
|
||||
每P时间
|
||||
<input class="form-input border-0 border-b-2 w-full" type="time" step="1" name="each_time" value="{{ old("each_time") }}">
|
||||
</label>
|
||||
@include("common.form_error")
|
||||
<div class="block my-2 text-center">
|
||||
<input class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" type="submit" value="修复该录播下的所有节目开始时间">
|
||||
</div>
|
||||
</form>
|
||||
@include("common.footer")
|
||||
</body>
|
||||
</html>
|
@ -48,6 +48,8 @@ Route::prefix("/programs/construct")->middleware("auth:web")->group(function (Ro
|
||||
$router->post("/{program}/video/add", ["\\App\\Http\\Controllers\\ProgramVideoConstructController","create"])->name("program.construct.video.create");
|
||||
$router->get("/video/{program_video}", ["\\App\\Http\\Controllers\\ProgramVideoConstructController","edit"])->name("program.construct.video.edit");
|
||||
$router->post("/video/{program_video}", ["\\App\\Http\\Controllers\\ProgramVideoConstructController","submit"])->name("program.construct.video.submit");
|
||||
$router->get("/video/{program_video}/batch_fix", ["\\App\\Http\\Controllers\\ProgramVideoConstructController","to_fix_created_at"])->name("program.construct.video.batch_fix_created_at");
|
||||
$router->post("/video/{program_video}/batch_fix", ["\\App\\Http\\Controllers\\ProgramVideoConstructController","fix_created_at_base_on"])->name("program.construct.video.batch_fix_created_at.submit");
|
||||
// 节目关联点播建设
|
||||
$router->get('/{program}/append', ["\\App\\Http\\Controllers\\ProgramAppendConstructController","index"])->name("program.construct.append.list");
|
||||
$router->get('/{program}/append/add', ["\\App\\Http\\Controllers\\ProgramAppendConstructController","add"])->name("program.construct.append.add");
|
||||
|
Loading…
x
Reference in New Issue
Block a user