抽象封装简化

This commit is contained in:
2022-08-24 21:12:25 +08:00
parent 5cbf9ff177
commit 9fb8a83fa5
4 changed files with 112 additions and 68 deletions

View File

@ -6,6 +6,7 @@ use App\Models\Programs;
use App\Models\ProgramVideos;
use App\Models\VideoComments;
use App\Models\VideoParts;
use App\Util\ProgramVideoUtil;
use App\Util\TimeUtil;
use Carbon\Carbon;
use Illuminate\Database\QueryException;
@ -97,30 +98,6 @@ class ProgramConstructController extends BaseController
$video_pivot->start_part = $match["part"];
$video_pivot->start_time = $time;
$video_pivot->stop_part = $match["part"];
if (sizeof($video_parts) > 0) {
/**
* 计算开始时间
* @var VideoParts $cur_part
*/
$cur_part = $video_parts->where("part_num", "=", $match["part"])->first();
if ($cur_part) {
// 根据标题名称,判断开始时间
$title = $cur_part->title;
$date_str = substr($title, 0, 13);
$base_time = Carbon::createFromFormat("Ymd_Hi", $date_str);
$start_time = Carbon::createFromFormat("H:i:s", $time);
$video_pivot->created_at = TimeUtil::calculate_program_time(
$base_time,
$start_time->secondsSinceMidnight()
);
if ($cur_part->duration->diffInMinutes($start_time) < 20) {
$video_pivot->stop_part += 1;
if ($video_pivot->stop_part > $video_parts->pluck("part_num")->max()) {
$video_pivot->stop_part = $video_parts->pluck("part_num")->max();
}
}
}
}
$program->save();
$program->video_pivots()->save($video_pivot);
}
@ -131,6 +108,7 @@ class ProgramConstructController extends BaseController
"content" => $e->getMessage()
]);
}
ProgramVideoUtil::fix_created_at_by_part_info($bvid);
return redirect(route("program.construct.list"));
}