添加建设内容

This commit is contained in:
Jerry Yan 2022-07-29 10:45:13 +08:00
parent d0e816ec6e
commit 4f31bd50c3
17 changed files with 446 additions and 23 deletions

View File

@ -0,0 +1,35 @@
<?php
namespace App\Http\Controllers;
use App\Models\Programs;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
class ProgramConstructController extends BaseController
{
public function construct(Request $request) {
$keyword = $request->get("keyword", "");
$programs = Programs::query()->with(["appends", "video_pivots.video"])->where("status", "=", 0)->limit(15)->orderByDesc("created_at")->get();
return view("program.construct.index", [
"keyword" => $keyword,
"programs"=>$programs,
]);
}
public function edit(Request $request, Programs $program) {
return view("program.construct.create", [
"program"=>$program
]);
}
public function submit(Request $request, Programs $program) {
$updatePayload = $request->only(["name", "difficulty", "desc"]);
$program->status = $request->post("status", 0);
$program->created_at = $request->post("created_at");
$program->update($updatePayload);
return view("program.construct.create", [
"program"=>$program
]);
}
}

View File

@ -10,8 +10,8 @@ class ProgramQueryController extends BaseController
{
public function index(Request $request) {
$keyword = $request->get("keyword", "");
$programs = Programs::query()->with(["appends", "video_pivots.video"])->limit(15)->orderByDesc("created_at")->get();
return view("program", [
$programs = Programs::query()->with(["appends", "video_pivots.video"])->where("status", "=", 1)->limit(15)->orderByDesc("created_at")->get();
return view("program.index", [
"keyword" => $keyword,
"programs"=>$programs,
]);

View File

@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers;
use App\Models\Programs;
use App\Models\ProgramVideos;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Storage;
class ProgramVideoConstructController extends BaseController
{
public function index(Request $request, Programs $program) {
return view("program.construct.video.index", [
"program" => $program,
"videos" => $program->video_pivots,
]);
}
public function edit(Request $request, ProgramVideos $program_video) {
return view("program.construct.video.create", [
"program_video" => $program_video
]);
}
public function submit(Request $request, ProgramVideos $program_video) {
$updatePayload = $request->only(["start_part", "start_time", "stop_part", "stop_time"]);
if ($request->hasFile("start_image")) {
$file = $request->file("start_image");
$path = $file->store("lubo_file");
$full_path = Storage::url($path);
$program_video->start_image = str_replace("jerryyan.top", "jerryyan.net", $full_path);
}
if ($request->hasFile("stop_image")) {
$file = $request->file("stop_image");
$path = $file->store("lubo_file");
$full_path = Storage::url($path);
$program_video->stop_image = str_replace("jerryyan.top", "jerryyan.net", $full_path);
}
$program_video->update($updatePayload);
return view("program.construct.video.create", [
"program_video" => $program_video
]);
}
}

View File

@ -8,6 +8,8 @@ use Illuminate\Support\Carbon;
class ProgramVideos extends Model
{
protected $fillable = ["start_part", "start_time", "stop_part", "stop_time"];
protected $dateFormat = 'U';
public function program(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Programs::class, "program_id", "id");
@ -21,7 +23,20 @@ class ProgramVideos extends Model
public function startSec(): Attribute
{
return Attribute::get(function ($_, $attributes) {
if (!$attributes['start_time']) {
return "";
}
return Carbon::createFromFormat("H:i:s", $attributes['start_time'])->secondsSinceMidnight();
});
}
public function stopSec(): Attribute
{
return Attribute::get(function ($_, $attributes) {
if (!$attributes['stop_time']) {
return "";
}
return Carbon::createFromFormat("H:i:s", $attributes['stop_time'])->secondsSinceMidnight();
});
}
}

View File

@ -6,6 +6,8 @@ use Illuminate\Database\Eloquent\Model;
class Programs extends Model
{
protected $fillable = ["name", "difficulty", "desc"];
protected $dateFormat = 'U';
public function appends(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(ProgramAppends::class, "program_id", "id")->orderByDesc("is_original");

View File

@ -15,5 +15,8 @@
"lodash": "^4.17.19",
"postcss": "^8.1.14",
"tailwindcss": "^3.1.6"
},
"dependencies": {
"@tailwindcss/forms": "^0.5.2"
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,48 @@
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>录播节目修改</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="{{ asset('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">
<input type="hidden" name="id" value="{{$program->id}}">
<label class="block my-2">
节目名称
<input class="form-input border-0 border-b-2 w-full" type="text" name="name" value="{{$program->name}}">
</label>
<label class="block my-2">
节目难度
<input class="form-input border-0 border-b-2 w-full" type="text" name="difficulty" value="{{$program->difficulty}}">
</label>
<label class="block my-2">
节目要求
<input class="form-input border-0 border-b-2 w-full" type="text" name="desc" value="{{$program->desc}}">
</label>
<label class="block my-2">
节目开打时间
<input class="form-input border-0 border-b-2 w-full" type="datetime-local" step="1" name="created_at" value="{{$program->created_at}}">
</label>
<label class="block my-2">
是否结束维护
<input class="form-checkbox" type="checkbox" name="status" value="1" @if($program->status == 1) checked @endif>
</label>
<div class="block my-2 text-center">
<input class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" type="submit">
</div>
<div class="block my-2">
<a href="{{route("program.construct.video.list", ["program"=>$program->id])}}"
class="block px-6 py-2 inline-block rounded-full bg-cyan-600 text-white">
关联视频列表
</a>
</div>
</form>
<div class="w-full lg:w-1/2 lg:ml-6 flex justify-between px-4">
<a class="block px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" href="{{route("program.construct.edit", ["program"=>$program->id - 1])}}">上一个</a>
<a class="block px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" href="{{route("program.construct.edit", ["program"=>$program->id + 1])}}">下一个</a>
</div>
@include("common.footer")
</body>
</html>

View File

@ -7,25 +7,23 @@
</head>
<body>
@include("common.header")
<h3>搜索功能待开放,数据待补充完整</h3>
<!--<form action="">
<label for="keyword">查找节目关键词,空格隔开查找多个关键词</label>
<input type="text" name="keyword" id="keyword" value="{{$keyword}}">
<input type="submit">
</form>-->
<table border>
<table class="table-auto border-collapse w-full lg:border lg:border-black">
<thead>
<tr>
<tr class="border border-black sticky bg-white lg:static top-0 left-0 right-0">
<td>节目名称</td>
<td>点播及追加</td>
<td>视频地址及位置</td>
<td>结束时的画面</td>
<td>节目开始</td>
<td>节目结束时的画面</td>
</tr>
</thead>
<tbody>
@foreach($programs as $program)
<tr>
<td>{{$program->name}}</td>
<td>
<a href="{{route("program.construct.edit", ["program"=>$program->id])}}">编辑</a>
<span title="节目">{{$program->name}}</span>
<span title="要求">{{$program->desc}}</span>
</td>
<td>
@foreach($program->appends as $append)
@if($append->is_original)
@ -66,7 +64,11 @@
href="https://www.bilibili.com/video/{{$video_pivot->video_bvid}}?p={{$video_pivot->start_part}}&t={{$video_pivot->start_sec}}"
title="P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}"
>
节目开始位置
@if($video_pivot->start_image)
<img width="300" src="{{$video_pivot->start_image}}" alt="开始时的画面">
@else
节目开始位置
@endif
</a>
@endforeach
</td>

View File

@ -0,0 +1,62 @@
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>录播节目关联视频位置修改</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="{{ asset('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">
<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" 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" step="1" type="time" name="start_time" value="{{$program_video->start_time}}">
</label>
<label class="block my-2">
开始图像
@if($program_video->start_image)
<img src="{{$program_video->start_image}}" alt="开始图片">
@endif
<input class="form-input border-0 border-b-2 w-full" type="file" name="start_image">
</label>
<label class="block my-2">
结束P数
<input class="form-input border-0 border-b-2 w-full" type="number" name="stop_part" value="{{$program_video->stop_part}}">
</label>
<label class="block my-2">
结束时间
<input class="form-input border-0 border-b-2 w-full" step="1" type="time" name="stop_time" value="{{$program_video->stop_time}}">
</label>
<label class="block my-2">
结束图像
@if($program_video->stop_image)
<img src="{{$program_video->stop_image}}" alt="结束图片">
@endif
<input class="form-input border-0 border-b-2 w-full" type="file" name="stop_image">
</label>
<div class="block my-2 text-center">
<input class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" type="submit">
</div>
<div class="block my-2">
<a class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" target="_blank"
href="https://www.bilibili.com/video/{{$program_video->video_bvid}}?p={{$program_video->start_part}}&t={{$program_video->start_sec}}"
title="P{{$program_video->start_part}}#{{$program_video->start_time}}"
>打开至开始位置</a>
<a class="px-6 py-2 inline-block rounded-full bg-cyan-600 text-white" target="_blank"
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>
</div>
</form>
@include("common.footer")
</body>
</html>

View File

@ -0,0 +1,54 @@
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>录播节目查询</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="{{ asset('css/app.css') }}" rel="stylesheet"/>
</head>
<body>
@include("common.header")
<table class="table-auto border-collapse w-full lg:border lg:border-black">
<thead>
<tr class="border border-black sticky bg-white lg:static top-0 left-0 right-0">
<td>BVID</td>
<td>节目开始时间</td>
<td>节目开始时的画面</td>
<td>节目结束时的画面</td>
<td>操作</td>
</tr>
</thead>
<tbody>
@foreach($videos as $video_pivot)
<tr>
<td>
<a class="text-purple-600 underline" target="_blank"
href="https://www.bilibili.com/video/{{$video_pivot->video_bvid}}?p={{$video_pivot->start_part}}&t={{$video_pivot->start_sec}}"
title="P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}"
>{{$video_pivot->video_bvid}}</a>
</td>
<td>P{{$video_pivot->start_part}} {{$video_pivot->start_time}}</td>
<td>
@if($video_pivot->start_image)
<img width="300" src="{{$video_pivot->start_image}}" alt="开始时的画面">
@else
<div>暂无</div>
@endif
</td>
<td>
@if($video_pivot->stop_image)
<img width="300" src="{{$video_pivot->stop_image}}" alt="结束时的画面">
@else
<div>暂无</div>
@endif
</td>
<td>
<a class="text-blue-600 underline"
href="{{route("program.construct.video.edit", ["program_video" => $video_pivot->id])}}">编辑</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@include("common.footer")
</body>
</html>

View File

@ -0,0 +1,132 @@
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>录播节目查询</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="{{ asset('css/app.css') }}" rel="stylesheet"/>
</head>
<body>
@include("common.header")
<h3>搜索功能待开放,数据待补充完整</h3>
<!--<form action="">
<label for="keyword">查找节目关键词,空格隔开查找多个关键词</label>
<input type="text" name="keyword" id="keyword" value="{{$keyword}}">
<input type="submit">
</form>-->
<table class="table-auto border-collapse w-full lg:border lg:border-black">
<thead>
<tr class="border border-black sticky bg-white lg:static top-0 left-0 right-0">
<td>节目名称</td>
<td>点播及追加</td>
<td>节目开始</td>
<td>节目结束</td>
</tr>
</thead>
<tbody>
@foreach($programs as $program)
<tr>
<td>
<span title="节目">{{$program->name}}</span>
<span title="难度">{{$program->difficulty}}</span>
<span title="要求">{{$program->desc}}</span>
</td>
<td>
@foreach($program->appends as $append)
@if($append->is_original)
<div>
@switch($append->platform_id)
@case(1)
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/bilibili.ico" alt="B站">
<a class="underline" href="https://space.bilibili.com/{{$append->from_mid}}" target="_blank">{{$append->from}}</a>
@break
@case(2)
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/ixigua.ico" alt="西瓜视频">
<a class="underline" href="https://www.ixigua.com/home/{{$append->from_mid}}/" target="_blank">{{$append->from}}</a>
@break
@case(3)
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/douyin.ico" alt="抖音">
{{$append->from}}
@break
@default
{{$append->from}}
@break
@endswitch
老板点播
<span title="一分10块">{{$append->price}}</span>
@if($append->append)
<span>{{$append->append}}</span>
@endif
</div>
@else
<div>
@switch($append->platform_id)
@case(1)
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/bilibili.ico" alt="B站">
<a class="underline" href="https://space.bilibili.com/{{$append->from_mid}}" target="_blank">{{$append->from}}</a>
@break
@case(2)
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/ixigua.ico" alt="西瓜视频">
<a class="underline" href="https://www.ixigua.com/home/{{$append->from_mid}}/" target="_blank">{{$append->from}}</a>
@break
@case(3)
<img class="w-4 h-4 inline-block" src="https://cdn.jerryyan.net/luboimg/douyin.ico" alt="抖音">
{{$append->from}}
@break
@default
{{$append->from}}
@break
@endswitch
老板追加:{{$append->name}}
<span title="一分10块">{{$append->price}}</span>
@if($append->append)
<span>{{$append->append}}</span>
@endif
</div>
@endif
@endforeach
</td>
<td>
@foreach($program->video_pivots as $video_pivot)
<a
target="_blank"
href="https://www.bilibili.com/video/{{$video_pivot->video_bvid}}?p={{$video_pivot->start_part}}&t={{$video_pivot->start_sec}}"
title="P{{$video_pivot->start_part}}#{{$video_pivot->start_time}}"
>
@if($video_pivot->start_image)
<img width="300" src="{{$video_pivot->start_image}}" alt="开始时的画面">
@else
节目开始位置
@endif
</a>
@endforeach
</td>
<td>
@foreach($program->video_pivots as $video_pivot)
@if($video_pivot->stop_part)
<a
target="_blank"
href="https://www.bilibili.com/video/{{$video_pivot->video_bvid}}?p={{$video_pivot->stop_part}}&t={{$video_pivot->stop_sec}}"
title="P{{$video_pivot->stop_part}}#{{$video_pivot->stop_time}}"
>
@if($video_pivot->start_image)
<img width="300" src="{{$video_pivot->stop_image}}" alt="结束时的画面">
@else
节目结束位置
@endif
</a>
@else
@if($video_pivot->stop_image)
<img width="300" src="{{$video_pivot->stop_image}}" alt="结束时的画面">
@else
<div>暂无</div>
@endif
@endif
@endforeach
</td>
</tr>
@endforeach
</tbody>
</table>
@include("common.footer")
</body>
</html>

View File

@ -12,10 +12,21 @@ use Illuminate\Support\Facades\Route;
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', "\\App\\Http\\Controllers\\CommentQueryController@index");
Route::get('/programs', "\\App\\Http\\Controllers\\ProgramQueryController@index");
Route::get('/danmakus', "\\App\\Http\\Controllers\\DanmakuQueryController@index");
Route::get('/danmakus/{bvid}', "\\App\\Http\\Controllers\\DanmakuQueryController@specific_search");
Route::get('/upload', "\\App\\Http\\Controllers\\FileController@index");
Route::post('/upload', "\\App\\Http\\Controllers\\FileController@upload");
// 对外列表
Route::get('/', ["\\App\\Http\\Controllers\\CommentQueryController","index"]);
Route::get('/programs', ["\\App\\Http\\Controllers\\ProgramQueryController","index"]);
Route::get('/danmakus', ["\\App\\Http\\Controllers\\DanmakuQueryController","index"]);
Route::get('/danmakus/{bvid}', ["\\App\\Http\\Controllers\\DanmakuQueryController","specific_search"]);
Route::get('/upload', ["\\App\\Http\\Controllers\\FileController","index"]);
Route::post('/upload', ["\\App\\Http\\Controllers\\FileController","upload"]);
// 建设部分
Route::get('/programs/construct', ["\\App\\Http\\Controllers\\ProgramConstructController","construct"])->name("program.construct.list");
Route::get('/programs/construct/{program}', ["\\App\\Http\\Controllers\\ProgramConstructController","edit"])->name("program.construct.edit");
Route::post('/programs/construct/{program}', ["\\App\\Http\\Controllers\\ProgramConstructController", "submit"])->name("program.construct.submit");
Route::get("/programs/construct/{program}/video", ["\\App\\Http\\Controllers\\ProgramVideoConstructController","index"])->name("program.construct.video.list");
Route::get("/programs/construct/video/{program_video}", ["\\App\\Http\\Controllers\\ProgramVideoConstructController","edit"])->name("program.construct.video.edit");
Route::post("/programs/construct/video/{program_video}", ["\\App\\Http\\Controllers\\ProgramVideoConstructController","submit"])->name("program.construct.video.submit");
Route::get('/programs/construct/{program}/append', ["\\App\\Http\\Controllers\\ProgramAppendConstructController","construct"])->name("program.construct.append.list");
Route::post('/programs/construct/{program}/append', ["\\App\\Http\\Controllers\\ProgramAppendConstructController","create"])->name("program.construct.append.create");
Route::get('/programs/construct/{program}/append/{program_append}', ["\\App\\Http\\Controllers\\ProgramAppendConstructController","edit"])->name("program.construct.append.edit");
Route::post('/programs/construct/{program}/append/{program_append}', ["\\App\\Http\\Controllers\\ProgramAppendConstructController","submit"])->name("program.construct.append.submit");

View File

@ -8,5 +8,7 @@ module.exports = {
theme: {
extend: {},
},
plugins: [],
plugins: [
require('@tailwindcss/forms')
],
}

View File

@ -994,6 +994,13 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"
"@tailwindcss/forms@^0.5.2":
version "0.5.2"
resolved "https://registry.npmmirror.com/@tailwindcss/forms/-/forms-0.5.2.tgz#4ef45f9916dcb37838cbe7fecdcc4ba7a7c2ab59"
integrity sha512-pSrFeJB6Bg1Mrg9CdQW3+hqZXAKsBrSG9MAfFLKy1pVA4Mb4W7C0k7mEhlmS2Dfo/otxrQOET7NJiJ9RrS563w==
dependencies:
mini-svg-data-uri "^1.2.3"
"@trysound/sax@0.2.0":
version "0.2.0"
resolved "https://registry.npmmirror.com/@trysound/sax/-/sax-0.2.0.tgz#cccaab758af56761eb7bf37af6f03f326dd798ad"
@ -3515,6 +3522,11 @@ mini-css-extract-plugin@^1.6.2:
schema-utils "^3.0.0"
webpack-sources "^1.1.0"
mini-svg-data-uri@^1.2.3:
version "1.4.4"
resolved "https://registry.npmmirror.com/mini-svg-data-uri/-/mini-svg-data-uri-1.4.4.tgz#8ab0aabcdf8c29ad5693ca595af19dd2ead09939"
integrity sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==
minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1:
version "1.0.1"
resolved "https://registry.npmmirror.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7"