From eff07c4f7205f1be61a9068cc1463b0eafcbf506 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 8 Aug 2022 09:54:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E6=89=93=E6=97=B6=E9=97=B4=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E4=BF=AE=E5=A4=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProgramVideoConstructController.php | 54 +++++++++++++++++++ .../program/construct/video/create.blade.php | 3 ++ .../construct/video/time_fix.blade.php | 40 ++++++++++++++ routes/web.php | 2 + 4 files changed, 99 insertions(+) create mode 100644 resources/views/program/construct/video/time_fix.blade.php diff --git a/app/Http/Controllers/ProgramVideoConstructController.php b/app/Http/Controllers/ProgramVideoConstructController.php index 8ace2a5..68ffa83 100644 --- a/app/Http/Controllers/ProgramVideoConstructController.php +++ b/app/Http/Controllers/ProgramVideoConstructController.php @@ -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")); + } } diff --git a/resources/views/program/construct/video/create.blade.php b/resources/views/program/construct/video/create.blade.php index e3b9099..41cd549 100644 --- a/resources/views/program/construct/video/create.blade.php +++ b/resources/views/program/construct/video/create.blade.php @@ -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}}" >打开至结束位置 + $program_video->id])) }}" + >去批量修复开打时间 @endif diff --git a/resources/views/program/construct/video/time_fix.blade.php b/resources/views/program/construct/video/time_fix.blade.php new file mode 100644 index 0000000..588aa77 --- /dev/null +++ b/resources/views/program/construct/video/time_fix.blade.php @@ -0,0 +1,40 @@ + + + + 录播节目关联视频位置修改 + + + + +@include("common.header") +
+
时间基准信息
+ + + + + + + @include("common.form_error") +
+ +
+
+@include("common.footer") + + diff --git a/routes/web.php b/routes/web.php index 6f260bc..936f336 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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");