Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
media-resource
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨昕
media-resource
Commits
ca92bafb
Commit
ca92bafb
authored
Apr 02, 2021
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改导出格式
parent
ef0a079d
Pipeline
#14109
passed with stages
in 3 minutes 37 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
25 deletions
+35
-25
MubanExport.php
app/Exports/MubanExport.php
+1
-3
MediaController.php
app/Http/Controllers/Web/MediaController.php
+4
-7
MediaModel.php
app/Model/MediaModel.php
+30
-15
No files found.
app/Exports/MubanExport.php
View file @
ca92bafb
...
@@ -11,7 +11,6 @@ use Maatwebsite\Excel\Concerns\WithStyles;
...
@@ -11,7 +11,6 @@ use Maatwebsite\Excel\Concerns\WithStyles;
use
PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
;
use
PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
;
class
MubanExport
implements
WithColumnWidths
,
WithHeadings
,
FromArray
,
WithStyles
class
MubanExport
implements
WithColumnWidths
,
WithHeadings
,
FromArray
,
WithStyles
{
{
use
Exportable
;
use
Exportable
;
...
@@ -42,7 +41,7 @@ class MubanExport implements WithColumnWidths,WithHeadings,FromArray,WithStyles
...
@@ -42,7 +41,7 @@ class MubanExport implements WithColumnWidths,WithHeadings,FromArray,WithStyles
return
[
return
[
[
""
,
"【第一章马克思主义哲学是科学的世界观和方法论第一节哲学及其基本问题】.mp4"
,
"mda-250f994a93f2688ba225532c641b2a34"
],
[
""
,
"【第一章马克思主义哲学是科学的世界观和方法论第一节哲学及其基本问题】.mp4"
,
"mda-250f994a93f2688ba225532c641b2a34"
],
[
""
,
"【19课堂】2021.03.02-月半时政-脱贫攻坚-公基-李浩祥】.mp4"
,
"mda-a4c0ad458d3592ff798277a42cb57be6"
],
[
""
,
"【19课堂】2021.03.02-月半时政-脱贫攻坚-公基-李浩祥】.mp4"
,
"mda-a4c0ad458d3592ff798277a42cb57be6"
],
[
""
,
"
第二列
是非必填项"
,
"媒资编号为必填项"
]
[
""
,
"
视频名称
是非必填项"
,
"媒资编号为必填项"
]
];
];
}
}
...
@@ -54,5 +53,4 @@ class MubanExport implements WithColumnWidths,WithHeadings,FromArray,WithStyles
...
@@ -54,5 +53,4 @@ class MubanExport implements WithColumnWidths,WithHeadings,FromArray,WithStyles
];
];
}
}
}
}
app/Http/Controllers/Web/MediaController.php
View file @
ca92bafb
...
@@ -11,7 +11,9 @@ use App\Tool\SrsHookValidate;
...
@@ -11,7 +11,9 @@ use App\Tool\SrsHookValidate;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Support\Facades\App
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Qiniu\Auth
;
class
MediaController
extends
Controller
class
MediaController
extends
Controller
...
@@ -262,7 +264,8 @@ class MediaController extends Controller
...
@@ -262,7 +264,8 @@ class MediaController extends Controller
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
*/
public
function
batch_media
(
Request
$request
){
public
function
batch_media
(
Request
$request
){
return
view
(
'admin.media.batch_media'
);
return
view
(
'admin.media.batch_media'
,
$request
->
all
());
}
}
/**
/**
...
@@ -276,7 +279,6 @@ class MediaController extends Controller
...
@@ -276,7 +279,6 @@ class MediaController extends Controller
$data
=
handler_drive
(
function
()
use
(
$request
){
$data
=
handler_drive
(
function
()
use
(
$request
){
$file
=
$request
->
file
(
'uploadFile'
);
$file
=
$request
->
file
(
'uploadFile'
);
#将文件内容转化为数组
#将文件内容转化为数组
...
@@ -291,10 +293,8 @@ class MediaController extends Controller
...
@@ -291,10 +293,8 @@ class MediaController extends Controller
$data
=
[];
$data
=
[];
if
(
!
empty
(
$sheet
[
0
])){
if
(
!
empty
(
$sheet
[
0
])){
#批量获取永久播放链接地址
#批量获取永久播放链接地址
$mediaInfos
=
MediaModel
::
batchGetMediaForverM3u8
(
$request
,
$media_ids
);
$mediaInfos
=
MediaModel
::
batchGetMediaForverM3u8
(
$request
,
$media_ids
);
$data
=
new
MediasExport
(
array_values
(
$mediaInfos
));
$data
=
new
MediasExport
(
array_values
(
$mediaInfos
));
}
}
...
@@ -302,9 +302,6 @@ class MediaController extends Controller
...
@@ -302,9 +302,6 @@ class MediaController extends Controller
});
});
return
Excel
::
download
(
$data
,
$type
.
'.xlsx'
);
return
Excel
::
download
(
$data
,
$type
.
'.xlsx'
);
}
}
...
...
app/Model/MediaModel.php
View file @
ca92bafb
...
@@ -1043,30 +1043,45 @@ class MediaModel extends Eloquent
...
@@ -1043,30 +1043,45 @@ class MediaModel extends Eloquent
* @param $media_ids
* @param $media_ids
* @return mixed
* @return mixed
*/
*/
private
static
function
mediaExportFormat
(
array
$data
,
$media_ids
){
private
static
function
mediaExportFormat
(
array
$data
){
$medias
=
MediaModel
::
select
(
'_id'
,
'media_name'
)
->
whereIn
(
'_id'
,
$media_ids
)
->
limit
(
self
::
$max_page_size
)
->
get
()
->
toArray
();
foreach
(
$data
as
$key
=>
&
$item
){
foreach
(
$medias
as
$key
=>
&
$item
){
$item
[
'forvery_url'
]
=
isset
(
$data
[
$item
[
'_id'
]])
?
$data
[
$item
[
'_id'
]][
'url'
]
:
''
;
if
(
empty
(
$item
)){
$item
[
'_id'
]
=
$key
;
$item
[
'media_name'
]
=
'未查到相关数据'
;
$item
[
'forvery_url'
]
=
'未查到相关数据'
;
$item
[
'is_full_url'
]
=
"未查到相关数据"
;
$media_id
=
$item
[
'_id'
];
$media_num
=
md5
(
md5
(
$media_id
));
//生成媒资序列号,生成视频预览链接需要
$tmp
=
[
'media_num'
=>
$media_num
,
];
MediaModel
::
where
(
"_id"
,
$media_id
)
->
update
(
$tmp
);
$url
=
getenv
(
'preview_domain'
)
?
getenv
(
'preview_domain'
)
:
"https://xue.t.eoffcn.com/preview/temp/"
;
}
else
{
$media
=
MediaModel
::
select
(
'media_name'
)
->
where
(
'_id'
,
$item
[
'id'
])
->
first
();
$item
[
'is_full_url'
]
=
$url
.
"player"
.
'/'
.
$media_num
;
$media_id
=
$item
[
'id'
];
}
$media_num
=
md5
(
md5
(
$media_id
));
$item
[
'_id'
]
=
$item
[
'id'
];
$item
[
'media_name'
]
=
$media
[
'media_name'
];
return
$medias
;
$tmp
=
[
'media_num'
=>
$media_num
,
];
MediaModel
::
where
(
"_id"
,
$media_id
)
->
update
(
$tmp
);
$url
=
getenv
(
'preview_domain'
)
?
getenv
(
'preview_domain'
)
:
"https://xue.t.eoffcn.com/preview/temp/"
;
$item
[
'forvery_url'
]
=
$item
[
'url'
];
$item
[
'is_full_url'
]
=
$url
.
"player"
.
'/'
.
$media_num
;
unset
(
$item
[
'id'
]);
unset
(
$item
[
'key'
]);
unset
(
$item
[
'status'
]);
unset
(
$item
[
'url'
]);
}
}
return
$data
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment