mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-02-04 06:54:41 +08:00
fix default playSource and update upload manage
This commit is contained in:
@@ -59,7 +59,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<p>
|
<p>
|
||||||
<el-button type="warning" class="player" size="large" @click="play({episode:0,source:0})" round>
|
<el-button type="warning" class="player" size="large" @click="play({episode:0,source:data.detail.list[0].id})" round>
|
||||||
<el-icon>
|
<el-icon>
|
||||||
<CaretRight/>
|
<CaretRight/>
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -155,6 +155,32 @@ const handleLongText = (t: string): string => {
|
|||||||
return res.trimEnd()
|
return res.trimEnd()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 播放源切换
|
||||||
|
const changeTab = (id:string)=>{
|
||||||
|
data.currentTabId = id
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选集播放点击事件
|
||||||
|
const play = (change: { source: string, episode: number }) => {
|
||||||
|
router.push({path: `/play`, query: {id: `${router.currentRoute.value.query.link}`, ...change}})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 内容展开收起效果
|
||||||
|
const multiBtn = ref({state: false, text: '展开'})
|
||||||
|
const textContent = ref()
|
||||||
|
const showContent = (flag: boolean) => {
|
||||||
|
if (flag) {
|
||||||
|
multiBtn.value = {state: !flag, text: '展开'}
|
||||||
|
textContent.value.style.webkitLineClamp = 2
|
||||||
|
return
|
||||||
|
}
|
||||||
|
multiBtn.value = {state: !flag, text: '收起'}
|
||||||
|
textContent.value.style.webkitLineClamp = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
// 页面加载数据初始化
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
let link = router.currentRoute.value.query.link
|
let link = router.currentRoute.value.query.link
|
||||||
ApiGet('/filmDetail', {id: link}).then((resp: any) => {
|
ApiGet('/filmDetail', {id: link}).then((resp: any) => {
|
||||||
@@ -179,29 +205,6 @@ onBeforeMount(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 播放源切换
|
|
||||||
const changeTab = (id:string)=>{
|
|
||||||
data.currentTabId = id
|
|
||||||
}
|
|
||||||
|
|
||||||
// 选集播放点击事件
|
|
||||||
const play = (change: { source: string, episode: number }) => {
|
|
||||||
router.push({path: `/play`, query: {id: `${router.currentRoute.value.query.link}`, ...change}})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 内容展开收起效果
|
|
||||||
const multiBtn = ref({state: false, text: '展开'})
|
|
||||||
const textContent = ref()
|
|
||||||
const showContent = (flag: boolean) => {
|
|
||||||
if (flag) {
|
|
||||||
multiBtn.value = {state: !flag, text: '展开'}
|
|
||||||
textContent.value.style.webkitLineClamp = 2
|
|
||||||
return
|
|
||||||
}
|
|
||||||
multiBtn.value = {state: !flag, text: '收起'}
|
|
||||||
textContent.value.style.webkitLineClamp = 8
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ const data = reactive({
|
|||||||
list: [],
|
list: [],
|
||||||
},
|
},
|
||||||
current: {index: 0, episode: '', link: ''},
|
current: {index: 0, episode: '', link: ''},
|
||||||
currentTabName: '',
|
|
||||||
currentEpisode: 0,
|
currentEpisode: 0,
|
||||||
relate: [],
|
relate: [],
|
||||||
currentTabId: '', // 当前播放源ID
|
currentTabId: '', // 当前播放源ID
|
||||||
@@ -152,27 +151,7 @@ const hasNext = computed(() => {
|
|||||||
|
|
||||||
// 获取路由信息
|
// 获取路由信息
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
onBeforeMount(() => {
|
|
||||||
let query = router.currentRoute.value.query
|
|
||||||
ApiGet(`/filmPlayInfo`, {id: query.id, playFrom: query.source, episode: query.episode}).then((resp: any) => {
|
|
||||||
if (resp.code === 0) {
|
|
||||||
data.detail = resp.data.detail
|
|
||||||
data.current = {index: resp.data.currentEpisode, ...resp.data.current}
|
|
||||||
// data.currentPlayFrom = resp.data.currentPlayFrom
|
|
||||||
data.currentEpisode = resp.data.currentEpisode
|
|
||||||
data.relate = resp.data.relate
|
|
||||||
// 设置当前选中的播放源
|
|
||||||
data.currentTabName = `tab-${query.source}`
|
|
||||||
// 设置当前的视频播放url
|
|
||||||
data.options.src = data.current.link
|
|
||||||
// 设置当前播放源ID信息
|
|
||||||
data.currentTabId = resp.data.currentPlayFrom
|
|
||||||
data.loading = true
|
|
||||||
} else {
|
|
||||||
ElMessage.error({message: resp.msg})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
// 点击播集数播放对应影片
|
// 点击播集数播放对应影片
|
||||||
const playChange = (play: { sourceId: string, episodeIndex: number, target: any }) => {
|
const playChange = (play: { sourceId: string, episodeIndex: number, target: any }) => {
|
||||||
@@ -278,6 +257,27 @@ const saveFilmHisroy = ()=>{
|
|||||||
// 在浏览器关闭前或页面刷新前将当前影片的观看信息存入历史记录中
|
// 在浏览器关闭前或页面刷新前将当前影片的观看信息存入历史记录中
|
||||||
window.addEventListener('beforeunload',saveFilmHisroy)
|
window.addEventListener('beforeunload',saveFilmHisroy)
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化页面数据
|
||||||
|
onBeforeMount(() => {
|
||||||
|
let query = router.currentRoute.value.query
|
||||||
|
ApiGet(`/filmPlayInfo`, {id: query.id, playFrom: query.source, episode: query.episode}).then((resp: any) => {
|
||||||
|
if (resp.code === 0) {
|
||||||
|
data.detail = resp.data.detail
|
||||||
|
data.current = {index: resp.data.currentEpisode, ...resp.data.current}
|
||||||
|
// data.currentPlayFrom = resp.data.currentPlayFrom
|
||||||
|
data.currentEpisode = resp.data.currentEpisode
|
||||||
|
data.relate = resp.data.relate
|
||||||
|
// 设置当前的视频播放url
|
||||||
|
data.options.src = data.current.link
|
||||||
|
// 设置当前播放源ID信息
|
||||||
|
data.currentTabId = resp.data.currentPlayFrom
|
||||||
|
data.loading = true
|
||||||
|
} else {
|
||||||
|
ElMessage.error({message: resp.msg})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="间隔时长">
|
<el-form-item label="间隔时长">
|
||||||
<el-tooltip class="box-item" effect="dark" content="单次采集请求的时间间隔, 单位/ms" placement="top">
|
<el-tooltip class="box-item" effect="dark" content="单次采集请求的时间间隔, 单位/ms" placement="top">
|
||||||
<el-input-number v-model="form.add.interval" :step="100" step-strictly />
|
<el-input-number v-model="form.add.interval" :min="0" :step="100" step-strictly />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="接口类型">
|
<el-form-item label="接口类型">
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="间隔时长">
|
<el-form-item label="间隔时长">
|
||||||
<el-tooltip class="box-item" effect="dark" content="单次采集请求的时间间隔, 单位/ms" placement="top">
|
<el-tooltip class="box-item" effect="dark" content="单次采集请求的时间间隔, 单位/ms" placement="top">
|
||||||
<el-input-number v-model="form.edit.interval" :step="100" step-strictly />
|
<el-input-number v-model="form.edit.interval" :min="0" :step="100" step-strictly />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="接口类型">
|
<el-form-item label="接口类型">
|
||||||
|
|||||||
@@ -1,41 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="title_container">
|
<!-- <div class="title_container">
|
||||||
<h3>文件上传</h3>
|
<h3>海报墙预览</h3>
|
||||||
</div>
|
</div>-->
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<el-upload v-model:file-list="data.photoWall" action="#" list-type="picture-card"
|
<el-upload v-model:file-list="data.photoWall" action="#" list-type="picture-card"
|
||||||
:on-remove="handleRemove" :http-request="customUpload">
|
:on-remove="handleRemove" :http-request="customUpload">
|
||||||
<template #file="{ file }">
|
<template #file="{ file }">
|
||||||
<div>
|
<el-image class="el-upload-list__item-thumbnail" style="width: 100%;height: 100%" :src="file.link" fit="cover" />
|
||||||
<el-image class="el-upload-list__item-thumbnail" :src="file.link" fit="cover" />
|
|
||||||
<span class="el-upload-list__item-actions">
|
<span class="el-upload-list__item-actions">
|
||||||
<span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
|
<span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
|
||||||
<el-icon><zoom-in /></el-icon>
|
<el-icon><zoom-in /></el-icon>
|
||||||
</span>
|
</span>
|
||||||
<span class="el-upload-list__item-delete">
|
<span class="el-upload-list__item-delete" v-if="false">
|
||||||
<el-icon><Download /></el-icon>
|
<el-icon><Download /></el-icon>
|
||||||
</span>
|
</span>
|
||||||
<span class="el-upload-list__item-delete">
|
<span class="el-upload-list__item-delete" @click="delImage(file)" >
|
||||||
<el-icon><Delete /></el-icon>
|
<el-icon><Delete /></el-icon>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
<el-icon><Plus /></el-icon>
|
<el-icon><Plus /></el-icon>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
|
|
||||||
<el-upload v-if="false" class="upload-demo" drag action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15" multiple>
|
<div class="pagination">
|
||||||
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
<el-pagination background layout="prev, pager, next"
|
||||||
<div class="el-upload__text">
|
:total="data.page.total" v-model:page-size="data.page.pageSize"
|
||||||
删除文件 或<em>点击上传</em>
|
v-model:current-page="data.page.current"
|
||||||
</div>
|
@change="getPhotoPage" hide-on-single-page/>
|
||||||
<template #tip>
|
</div>
|
||||||
<div class="el-upload__tip">
|
|
||||||
jpg/png files with a size less than 500kb
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -52,6 +45,7 @@ import {Preview} from "../../../components/Global/preview";
|
|||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
photoWall: [],
|
photoWall: [],
|
||||||
|
page: {current:1, pageSize: 39, pageNumber: 0, total: 0},
|
||||||
imgList:[""]
|
imgList:[""]
|
||||||
})
|
})
|
||||||
const customUpload = (options:any)=>{
|
const customUpload = (options:any)=>{
|
||||||
@@ -70,10 +64,12 @@ const customUpload = (options:any)=>{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页数据获取
|
||||||
const getPhotoPage = ()=>{
|
const getPhotoPage = ()=>{
|
||||||
ApiGet(`/manage/file/list`, ).then((resp: any) => {
|
ApiGet(`/manage/file/list`, {current: data.page.current} ).then((resp: any) => {
|
||||||
if (resp.code === 0) {
|
if (resp.code === 0) {
|
||||||
data.photoWall = resp.data
|
data.photoWall = resp.data.list
|
||||||
|
data.page = resp.data.page
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error({message: resp.msg})
|
ElMessage.error({message: resp.msg})
|
||||||
}
|
}
|
||||||
@@ -83,11 +79,18 @@ const getPhotoPage = ()=>{
|
|||||||
onMounted(()=>{
|
onMounted(()=>{
|
||||||
getPhotoPage()
|
getPhotoPage()
|
||||||
})
|
})
|
||||||
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
|
const delImage = (file:any)=>{
|
||||||
console.log(uploadFile, uploadFiles)
|
ApiGet(`/manage/file/del`, {id: file.ID} ).then((resp: any) => {
|
||||||
|
if (resp.code === 0) {
|
||||||
|
getPhotoPage()
|
||||||
|
ElMessage.success({message: resp.msg})
|
||||||
|
} else {
|
||||||
|
ElMessage.error({message: resp.msg})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
|
// 图片放大预览
|
||||||
const handlePictureCardPreview = (currentFile:any) => {
|
const handlePictureCardPreview = (currentFile:any) => {
|
||||||
let list = data.photoWall.map((item:any)=>{
|
let list = data.photoWall.map((item:any)=>{
|
||||||
return item.link
|
return item.link
|
||||||
@@ -101,7 +104,31 @@ const handlePictureCardPreview = (currentFile:any) => {
|
|||||||
background: var(--bg-light);
|
background: var(--bg-light);
|
||||||
}
|
}
|
||||||
.content {
|
.content {
|
||||||
display: flex;
|
width: 100%;
|
||||||
justify-content: start;
|
padding: 10px 0;
|
||||||
}
|
}
|
||||||
|
.title_container {
|
||||||
|
margin: 10px 0 10px 0;
|
||||||
|
}
|
||||||
|
:deep(.el-upload-list--picture-card ) {
|
||||||
|
padding: 10px 10px;
|
||||||
|
}
|
||||||
|
:deep(.el-upload-list__item ) {
|
||||||
|
margin: 10px auto!important;
|
||||||
|
}
|
||||||
|
:deep(.el-upload--picture-card){
|
||||||
|
margin: 10px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
padding: 20px 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-pagination) {
|
||||||
|
width: 100% !important;
|
||||||
|
justify-content: center;
|
||||||
|
--el-color-primary: var(--paging-parmary-color);
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -265,7 +265,6 @@ onMounted(() => {
|
|||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding-right: 50px;
|
padding-right: 50px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-pagination) {
|
:deep(.el-pagination) {
|
||||||
@@ -274,11 +273,6 @@ onMounted(() => {
|
|||||||
--el-color-primary: var(--paging-parmary-color);
|
--el-color-primary: var(--paging-parmary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
:deep(.el-select-dropdown__item) {
|
|
||||||
--el-color-primary: red !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
:deep(.el-pager li) {
|
:deep(.el-pager li) {
|
||||||
--el-pagination-button-bg-color: var(--btn-bg-linght);
|
--el-pagination-button-bg-color: var(--btn-bg-linght);
|
||||||
border: 1px solid var(--border-gray-color);
|
border: 1px solid var(--border-gray-color);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
1
film/data/nginx/html/assets/index-49277a9a.css
Normal file
1
film/data/nginx/html/assets/index-49277a9a.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -11,8 +11,8 @@
|
|||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8"/>
|
||||||
<title>(╥﹏╥)</title>
|
<title>(╥﹏╥)</title>
|
||||||
<link rel="stylesheet" href="//at.alicdn.com/t/c/font_3992367_chvdxwo1gkp.css">
|
<link rel="stylesheet" href="//at.alicdn.com/t/c/font_3992367_chvdxwo1gkp.css">
|
||||||
<script type="module" crossorigin src="/assets/index-25f85fdf.js"></script>
|
<script type="module" crossorigin src="/assets/index-156f5d7d.js"></script>
|
||||||
<link rel="stylesheet" href="/assets/index-8ca98118.css">
|
<link rel="stylesheet" href="/assets/index-49277a9a.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
@@ -15,20 +15,6 @@ const (
|
|||||||
// MAXGoroutine max goroutine, 执行spider中对协程的数量限制
|
// MAXGoroutine max goroutine, 执行spider中对协程的数量限制
|
||||||
MAXGoroutine = 10
|
MAXGoroutine = 10
|
||||||
|
|
||||||
// CornMovieUpdate 影片更新定时任务间隔
|
|
||||||
CornMovieUpdate = "0 0/20 * * * ?"
|
|
||||||
// UpdateInterval 获取最近几小时更新的影片 (h 小时) 默认3小时
|
|
||||||
UpdateInterval = "3"
|
|
||||||
// CornUpdateAll 每月28执行一次清库更新
|
|
||||||
CornUpdateAll = "0 0 2 28 * ?"
|
|
||||||
|
|
||||||
// SpiderCipher 设置Spider触发指令的验证
|
|
||||||
SpiderCipher = "Life in a different world from zero"
|
|
||||||
|
|
||||||
// ImgCacheFlag 是否开启将主站影片图片放入本地进行存储
|
|
||||||
ImgCacheFlag = false
|
|
||||||
//ImageDir = "./resource/static/images"
|
|
||||||
|
|
||||||
FilmPictureUploadDir = "./static/upload/gallery"
|
FilmPictureUploadDir = "./static/upload/gallery"
|
||||||
FilmPictureUrlPath = "/upload/pic/poster/"
|
FilmPictureUrlPath = "/upload/pic/poster/"
|
||||||
FilmPictureAccess = "/api/upload/pic/poster/"
|
FilmPictureAccess = "/api/upload/pic/poster/"
|
||||||
@@ -62,15 +48,6 @@ const (
|
|||||||
VirtualPictureKey = "VirtualPicture"
|
VirtualPictureKey = "VirtualPicture"
|
||||||
// MaxScanCount redis Scan 操作每次扫描的数据量, 每次最多扫描300条数据
|
// MaxScanCount redis Scan 操作每次扫描的数据量, 每次最多扫描300条数据
|
||||||
MaxScanCount = 300
|
MaxScanCount = 300
|
||||||
|
|
||||||
// SearchCount Search scan 识别范围
|
|
||||||
SearchCount = 3000
|
|
||||||
// SearchKeys Search Key Hash
|
|
||||||
SearchKeys = "SearchKeys"
|
|
||||||
// SearchScoreListKey 根据评分检索的key
|
|
||||||
SearchScoreListKey = "Search:SearchScoreList"
|
|
||||||
SearchTimeListKey = "Search:SearchTimeList"
|
|
||||||
SearchHeatListKey = "Search:SearchHeatList"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -106,8 +83,8 @@ const (
|
|||||||
SearchTableName = "search"
|
SearchTableName = "search"
|
||||||
UserTableName = "users"
|
UserTableName = "users"
|
||||||
UserIdInitialVal = 10000
|
UserIdInitialVal = 10000
|
||||||
PictureTableName = "picture"
|
FileTableName = "files"
|
||||||
|
|
||||||
//mysql服务配置信息 root:root 设置mysql账户的用户名和密码
|
//mysql服务配置信息 root:root 设置mysql账户的用户名和密码
|
||||||
|
|
||||||
MysqlDsn = "root:root@(mysql:3306)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local"
|
MysqlDsn = "root:root@(mysql:3306)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"server/logic"
|
"server/logic"
|
||||||
"server/model/system"
|
"server/model/system"
|
||||||
"server/plugin/common/util"
|
"server/plugin/common/util"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SingleUpload 单文件上传, 暂定为图片上传
|
// SingleUpload 单文件上传, 暂定为图片上传
|
||||||
@@ -24,13 +25,6 @@ func SingleUpload(c *gin.Context) {
|
|||||||
system.Failed(err.Error(), c)
|
system.Failed(err.Error(), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 创建文件保存路径, 如果不存在则创建
|
|
||||||
//if _, err = os.Stat(config.ImageDir); os.IsNotExist(err) {
|
|
||||||
// err = os.MkdirAll(config.ImageDir, os.ModePerm)
|
|
||||||
// if err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// 生成文件名, 保存文件到服务器
|
// 生成文件名, 保存文件到服务器
|
||||||
fileName := fmt.Sprintf("%s/%s%s", config.FilmPictureUploadDir, util.RandomString(8), filepath.Ext(file.Filename))
|
fileName := fmt.Sprintf("%s/%s%s", config.FilmPictureUploadDir, util.RandomString(8), filepath.Ext(file.Filename))
|
||||||
@@ -48,12 +42,68 @@ func SingleUpload(c *gin.Context) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MultipleUpload 批量文件上传
|
||||||
|
func MultipleUpload(c *gin.Context) {
|
||||||
|
// 获取执行操作的用户信息
|
||||||
|
v, ok := c.Get(config.AuthUserClaims)
|
||||||
|
if !ok {
|
||||||
|
system.Failed("上传失败, 当前用户信息异常", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 解析表单数据
|
||||||
|
form, err := c.MultipartForm()
|
||||||
|
if err != nil {
|
||||||
|
system.Failed(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 获取文件列表
|
||||||
|
files := form.File["files"]
|
||||||
|
|
||||||
|
// 解析当前登录的用户信息
|
||||||
|
uc := v.(*system.UserClaims)
|
||||||
|
|
||||||
|
// 遍历文件列表
|
||||||
|
var fileNames []string
|
||||||
|
for _, file := range files {
|
||||||
|
// 生成文件名, 保存文件到服务器
|
||||||
|
fileName := fmt.Sprintf("%s/%s%s", config.FilmPictureUploadDir, util.RandomString(8), filepath.Ext(file.Filename))
|
||||||
|
err = c.SaveUploadedFile(file, fileName)
|
||||||
|
if err != nil {
|
||||||
|
system.Failed(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 记录图片信息到系统表中, 并获取返回的图片访问路径
|
||||||
|
fileNames = append(fileNames, logic.FileL.SingleFileUpload(fileName, int(uc.UserID)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回图片访问地址以及成功的响应
|
||||||
|
system.Success(fileNames, "上传成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelFile 删除文件
|
||||||
|
func DelFile(c *gin.Context) {
|
||||||
|
id, err := strconv.ParseUint(c.DefaultQuery("id", ""), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
system.Failed("操作失败, 未获取到需删除的文件标识信息", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if e := logic.FileL.RemoveFileById(uint(id)); e != nil {
|
||||||
|
system.Failed(fmt.Sprint("删除失败", e.Error()), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
system.SuccessOnlyMsg("文件已删除", c)
|
||||||
|
}
|
||||||
|
|
||||||
// PhotoWall 照片墙数据
|
// PhotoWall 照片墙数据
|
||||||
func PhotoWall(c *gin.Context) {
|
func PhotoWall(c *gin.Context) {
|
||||||
|
current, err := strconv.Atoi(c.DefaultQuery("current", "1"))
|
||||||
|
if err != nil {
|
||||||
|
system.Failed("图片分页数据获取失败, 分页参数异常", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
// 获取系统保存的文件的图片分页数据
|
// 获取系统保存的文件的图片分页数据
|
||||||
page := system.Page{PageSize: 10, Current: 1}
|
page := system.Page{PageSize: 39, Current: current}
|
||||||
// 获取分页数据
|
// 获取分页数据
|
||||||
pl := logic.FileL.GetPhotoPage(&page)
|
pl := logic.FileL.GetPhotoPage(&page)
|
||||||
system.Success(pl, "图片分页数据获取成功", c)
|
system.Success(gin.H{"list": pl, "page": page}, "图片分页数据获取成功", c)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ func FilmPlayInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// 获取影片详情信息
|
// 获取影片详情信息
|
||||||
detail := logic.IL.GetFilmDetail(id)
|
detail := logic.IL.GetFilmDetail(id)
|
||||||
|
// 如果 playFrom 为空, 则设置默认播放源和默认影片数据
|
||||||
|
if len(playFrom) <= 1 && len(detail.List) > 0 {
|
||||||
|
playFrom = detail.List[0].Id
|
||||||
|
|
||||||
|
}
|
||||||
// 获取当前影片播放信息
|
// 获取当前影片播放信息
|
||||||
var currentPlay system.MovieUrlInfo
|
var currentPlay system.MovieUrlInfo
|
||||||
for _, v := range detail.List {
|
for _, v := range detail.List {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"server/config"
|
"server/config"
|
||||||
"server/model/system"
|
"server/model/system"
|
||||||
|
"server/plugin/common/util"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,15 +16,31 @@ var FileL FileLogic
|
|||||||
|
|
||||||
func (fl *FileLogic) SingleFileUpload(fileName string, uid int) string {
|
func (fl *FileLogic) SingleFileUpload(fileName string, uid int) string {
|
||||||
// 生成图片信息
|
// 生成图片信息
|
||||||
var p = system.Picture{Link: fmt.Sprint(config.FilmPictureAccess, filepath.Base(fileName)), Uid: uid, PicType: 0}
|
var f = system.FileInfo{Link: fmt.Sprint(config.FilmPictureAccess, filepath.Base(fileName)), Uid: uid, Type: 0}
|
||||||
p.PicUid = strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
|
f.Fid = strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
|
||||||
|
f.FileType = strings.TrimPrefix(filepath.Ext(fileName), ".")
|
||||||
// 记录图片信息到系统表中
|
// 记录图片信息到系统表中
|
||||||
system.SaveGallery(p)
|
system.SaveGallery(f)
|
||||||
return p.Link
|
return f.Link
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPhotoPage 获取系统内的图片分页信息
|
// GetPhotoPage 获取系统内的图片分页信息
|
||||||
func (fl *FileLogic) GetPhotoPage(page *system.Page) []system.Picture {
|
func (fl *FileLogic) GetPhotoPage(page *system.Page) []system.FileInfo {
|
||||||
return system.GetPicturePage(page)
|
// 设置必要参数
|
||||||
|
var tl = []string{"jpeg", "jpg", "png", "webp"}
|
||||||
|
return system.GetFileInfoPage(tl, page)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveFileById 删除文件信息
|
||||||
|
func (fl *FileLogic) RemoveFileById(id uint) error {
|
||||||
|
// 首先获取对应图片信息
|
||||||
|
f := system.GetFileInfoById(id)
|
||||||
|
// 通过f删除本地图片
|
||||||
|
err := util.RemoveFile(f.StoragePath())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// 删除图片的关联信息
|
||||||
|
system.DelFileInfo(id)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ var IL *IndexLogic
|
|||||||
|
|
||||||
// IndexPage 首页数据处理
|
// IndexPage 首页数据处理
|
||||||
func (i *IndexLogic) IndexPage() map[string]interface{} {
|
func (i *IndexLogic) IndexPage() map[string]interface{} {
|
||||||
//声明返回值
|
|
||||||
//Info := make(map[string]interface{})
|
|
||||||
// 首页请求时长较高, 采用redis进行缓存, 在定时任务更新影片时清除对应缓存
|
// 首页请求时长较高, 采用redis进行缓存, 在定时任务更新影片时清除对应缓存
|
||||||
// 判断是否存在缓存数据, 存在则直接将数据返回
|
// 判断是否存在缓存数据, 存在则直接将数据返回
|
||||||
Info := system.GetCacheData(config.IndexCacheKey)
|
Info := system.GetCacheData(config.IndexCacheKey)
|
||||||
@@ -34,21 +32,14 @@ func (i *IndexLogic) IndexPage() map[string]interface{} {
|
|||||||
// 1. 首页分类数据处理 导航分类数据处理, 只提供 电影 电视剧 综艺 动漫 四大顶级分类和其子分类
|
// 1. 首页分类数据处理 导航分类数据处理, 只提供 电影 电视剧 综艺 动漫 四大顶级分类和其子分类
|
||||||
tree := system.CategoryTree{Category: &system.Category{Id: 0, Name: "分类信息"}}
|
tree := system.CategoryTree{Category: &system.Category{Id: 0, Name: "分类信息"}}
|
||||||
sysTree := system.GetCategoryTree()
|
sysTree := system.GetCategoryTree()
|
||||||
// 由于采集源数据格式不一,因此采用名称匹配
|
// 只展示show=true的分页影片信息
|
||||||
//for _, c := range sysTree.Children {
|
|
||||||
// switch c.Category.Name {
|
|
||||||
// case "电影", "电影片", "连续剧", "电视剧", "综艺", "综艺片", "动漫", "动漫片":
|
|
||||||
// tree.Children = append(tree.Children, c)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
for _, c := range sysTree.Children {
|
for _, c := range sysTree.Children {
|
||||||
// 只针对一级分类进行处理
|
// 只针对一级分类进行处理
|
||||||
if c.Show {
|
if c.Show {
|
||||||
tree.Children = append(tree.Children, c)
|
tree.Children = append(tree.Children, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 返回分类信息
|
||||||
Info["category"] = tree
|
Info["category"] = tree
|
||||||
// 2. 提供用于首页展示的顶级分类影片信息, 每分类 14条数据
|
// 2. 提供用于首页展示的顶级分类影片信息, 每分类 14条数据
|
||||||
var list []map[string]interface{}
|
var list []map[string]interface{}
|
||||||
@@ -62,7 +53,7 @@ func (i *IndexLogic) IndexPage() map[string]interface{} {
|
|||||||
}
|
}
|
||||||
Info["content"] = list
|
Info["content"] = list
|
||||||
// 不存在首页数据缓存时将查询数据缓存到redis中
|
// 不存在首页数据缓存时将查询数据缓存到redis中
|
||||||
//system.DataCache(config.IndexCacheKey, Info)
|
system.DataCache(config.IndexCacheKey, Info)
|
||||||
return Info
|
return Info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,21 +6,24 @@ import (
|
|||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"log"
|
"log"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"server/config"
|
"server/config"
|
||||||
"server/plugin/common/util"
|
"server/plugin/common/util"
|
||||||
"server/plugin/db"
|
"server/plugin/db"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Picture 图片信息对象
|
// FileInfo 图片信息对象
|
||||||
type Picture struct {
|
type FileInfo struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Link string `json:"link"` // 图片链接
|
Link string `json:"link"` // 图片链接
|
||||||
Uid int `json:"uid"` // 上传人ID
|
Uid int `json:"uid"` // 上传人ID
|
||||||
RelevanceId int64 `json:"relevanceId"` // 关联资源ID
|
RelevanceId int64 `json:"relevanceId"` // 关联资源ID
|
||||||
PicType int `json:"picType"` // 图片类型 (0 影片封面, 1 用户头像)
|
Type int `json:"type"` // 文件类型 (0 影片封面, 1 用户头像)
|
||||||
PicUid string `json:"picUid"` // 图片唯一标识, 通常为文件名
|
Fid string `json:"fid"` // 图片唯一标识, 通常为文件名
|
||||||
//Size int `json:"size"` // 图片大小
|
FileType string `json:"fileType"` // 文件类型, txt, png, jpg
|
||||||
|
//Size int `json:"size"` // 文件大小
|
||||||
}
|
}
|
||||||
|
|
||||||
// VirtualPicture 采集入站,待同步的图片信息
|
// VirtualPicture 采集入站,待同步的图片信息
|
||||||
@@ -32,57 +35,80 @@ type VirtualPicture struct {
|
|||||||
//------------------------------------------------本地图库------------------------------------------------
|
//------------------------------------------------本地图库------------------------------------------------
|
||||||
|
|
||||||
// TableName 设置图片存储表的表名
|
// TableName 设置图片存储表的表名
|
||||||
func (p *Picture) TableName() string {
|
func (f *FileInfo) TableName() string {
|
||||||
return config.PictureTableName
|
return config.FileTableName
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatePictureTable 创建图片关联信息存储表
|
// StoragePath 获取文件的保存路径
|
||||||
func CreatePictureTable() {
|
func (f *FileInfo) StoragePath() string {
|
||||||
|
var storage string
|
||||||
|
switch f.FileType {
|
||||||
|
case "jpeg", "jpg", "png", "webp":
|
||||||
|
storage = strings.Replace(f.Link, config.FilmPictureAccess, fmt.Sprint(config.FilmPictureUploadDir, "/"), 1)
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return storage
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateFileTable 创建图片关联信息存储表
|
||||||
|
func CreateFileTable() {
|
||||||
// 如果不存在则创建表 并设置自增ID初始值为10000
|
// 如果不存在则创建表 并设置自增ID初始值为10000
|
||||||
if !ExistPictureTable() {
|
if !ExistFileTable() {
|
||||||
err := db.Mdb.AutoMigrate(&Picture{})
|
err := db.Mdb.AutoMigrate(&FileInfo{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Create Table Picture Failed: ", err)
|
log.Println("Create Table FileInfo Failed: ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExistPictureTable 是否存在Picture表
|
// ExistFileTable 是否存在Picture表
|
||||||
func ExistPictureTable() bool {
|
func ExistFileTable() bool {
|
||||||
// 1. 判断表中是否存在当前表
|
// 1. 判断表中是否存在当前表
|
||||||
return db.Mdb.Migrator().HasTable(&Picture{})
|
return db.Mdb.Migrator().HasTable(&FileInfo{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveGallery 保存图片关联信息
|
// SaveGallery 保存图片关联信息
|
||||||
func SaveGallery(p Picture) {
|
func SaveGallery(f FileInfo) {
|
||||||
db.Mdb.Create(&p)
|
db.Mdb.Create(&f)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExistPictureByRid 查找图片信息是否存在
|
// ExistFileInfoByRid 查找图片信息是否存在
|
||||||
func ExistPictureByRid(rid int64) bool {
|
func ExistFileInfoByRid(rid int64) bool {
|
||||||
var count int64
|
var count int64
|
||||||
db.Mdb.Model(&Picture{}).Where("relevance_id = ?", rid).Count(&count)
|
db.Mdb.Model(&FileInfo{}).Where("relevance_id = ?", rid).Count(&count)
|
||||||
return count > 0
|
return count > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPictureByRid 通过关联的资源id获取对应的图片信息
|
// GetFileInfoByRid 通过关联的资源id获取对应的图片信息
|
||||||
func GetPictureByRid(rid int64) Picture {
|
func GetFileInfoByRid(rid int64) FileInfo {
|
||||||
var p Picture
|
var f FileInfo
|
||||||
db.Mdb.Where("relevance_id = ?", rid).First(&p)
|
db.Mdb.Where("relevance_id = ?", rid).First(&f)
|
||||||
return p
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPicturePage(page *Page) []Picture {
|
// GetFileInfoById 通过ID获取对应的图片信息
|
||||||
var pl []Picture
|
func GetFileInfoById(id uint) FileInfo {
|
||||||
query := db.Mdb.Model(&Picture{})
|
var f = FileInfo{}
|
||||||
|
db.Mdb.First(&f, id)
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFileInfoPage 获取文件关联信息分页数据
|
||||||
|
func GetFileInfoPage(tl []string, page *Page) []FileInfo {
|
||||||
|
var fl []FileInfo
|
||||||
|
query := db.Mdb.Model(&FileInfo{}).Where("file_type IN ?", tl).Order("id DESC")
|
||||||
// 获取分页相关参数
|
// 获取分页相关参数
|
||||||
GetPage(query, page)
|
GetPage(query, page)
|
||||||
// 获取分页数据
|
// 获取分页数据
|
||||||
if err := query.Limit(page.PageSize).Offset((page.Current - 1) * page.PageSize).Find(&pl).Error; err != nil {
|
if err := query.Limit(page.PageSize).Offset((page.Current - 1) * page.PageSize).Find(&fl).Error; err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return pl
|
return fl
|
||||||
|
}
|
||||||
|
|
||||||
|
func DelFileInfo(id uint) {
|
||||||
|
db.Mdb.Unscoped().Delete(&FileInfo{}, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------图片同步------------------------------------------------
|
//------------------------------------------------图片同步------------------------------------------------
|
||||||
@@ -123,7 +149,7 @@ func SyncFilmPicture() {
|
|||||||
vp := VirtualPicture{}
|
vp := VirtualPicture{}
|
||||||
_ = json.Unmarshal([]byte(s.Member.(string)), &vp)
|
_ = json.Unmarshal([]byte(s.Member.(string)), &vp)
|
||||||
// 判断当前影片是否已经同步过图片, 如果已经同步则直接跳过后续逻辑
|
// 判断当前影片是否已经同步过图片, 如果已经同步则直接跳过后续逻辑
|
||||||
if ExistPictureByRid(vp.Id) {
|
if ExistFileInfoByRid(vp.Id) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 将图片同步到服务器中
|
// 将图片同步到服务器中
|
||||||
@@ -132,12 +158,13 @@ func SyncFilmPicture() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 完成同步后将图片信息保存到 Gallery 中
|
// 完成同步后将图片信息保存到 Gallery 中
|
||||||
SaveGallery(Picture{
|
SaveGallery(FileInfo{
|
||||||
Link: fmt.Sprint(config.FilmPictureAccess, fileName),
|
Link: fmt.Sprint(config.FilmPictureAccess, fileName),
|
||||||
Uid: config.UserIdInitialVal,
|
Uid: config.UserIdInitialVal,
|
||||||
RelevanceId: vp.Id,
|
RelevanceId: vp.Id,
|
||||||
PicType: 0,
|
Type: 0,
|
||||||
PicUid: regexp.MustCompile(`\.[^.]+$`).ReplaceAllString(fileName, ""),
|
Fid: regexp.MustCompile(`\.[^.]+$`).ReplaceAllString(fileName, ""),
|
||||||
|
FileType: strings.TrimPrefix(filepath.Ext(fileName), "."),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 递归执行直到图片暂存信息为空
|
// 递归执行直到图片暂存信息为空
|
||||||
@@ -147,21 +174,21 @@ func SyncFilmPicture() {
|
|||||||
// ReplaceDetailPic 将影片详情中的图片地址替换为自己的
|
// ReplaceDetailPic 将影片详情中的图片地址替换为自己的
|
||||||
func ReplaceDetailPic(d *MovieDetail) {
|
func ReplaceDetailPic(d *MovieDetail) {
|
||||||
// 查询影片对应的本地图片信息
|
// 查询影片对应的本地图片信息
|
||||||
if ExistPictureByRid(d.Id) {
|
if ExistFileInfoByRid(d.Id) {
|
||||||
// 如果存在关联的本地图片, 则查询对应的图片信息
|
// 如果存在关联的本地图片, 则查询对应的图片信息
|
||||||
p := GetPictureByRid(d.Id)
|
f := GetFileInfoByRid(d.Id)
|
||||||
// 替换采集站的图片链接为本地链接
|
// 替换采集站的图片链接为本地链接
|
||||||
d.Picture = p.Link
|
d.Picture = f.Link
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplaceBasicDetailPic 替换影片基本数据中的封面图为本地图片
|
// ReplaceBasicDetailPic 替换影片基本数据中的封面图为本地图片
|
||||||
func ReplaceBasicDetailPic(d *MovieBasicInfo) {
|
func ReplaceBasicDetailPic(d *MovieBasicInfo) {
|
||||||
// 查询影片对应的本地图片信息
|
// 查询影片对应的本地图片信息
|
||||||
if ExistPictureByRid(d.Id) {
|
if ExistFileInfoByRid(d.Id) {
|
||||||
// 如果存在关联的本地图片, 则查询对应的图片信息
|
// 如果存在关联的本地图片, 则查询对应的图片信息
|
||||||
p := GetPictureByRid(d.Id)
|
f := GetFileInfoByRid(d.Id)
|
||||||
// 替换采集站的图片链接为本地链接
|
// 替换采集站的图片链接为本地链接
|
||||||
d.Picture = p.Link
|
d.Picture = f.Link
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -640,10 +640,10 @@ func GetSearchInfosByTags(st SearchTagsVO, page *Page) []SearchInfo {
|
|||||||
qw = qw.Where("class_tag LIKE ?", fmt.Sprintf("%%%v%%", value))
|
qw = qw.Where("class_tag LIKE ?", fmt.Sprintf("%%%v%%", value))
|
||||||
case "sort":
|
case "sort":
|
||||||
if strings.EqualFold(value.(string), "release_stamp") {
|
if strings.EqualFold(value.(string), "release_stamp") {
|
||||||
qw.Order(fmt.Sprintf("year DESC ,%v Desc", value))
|
qw.Order(fmt.Sprintf("year DESC ,%v DESC", value))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
qw.Order(fmt.Sprintf("%v Desc", value))
|
qw.Order(fmt.Sprintf("%v DESC", value))
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ func TableInIt() {
|
|||||||
// 创建 Search Table
|
// 创建 Search Table
|
||||||
system.CreateSearchTable()
|
system.CreateSearchTable()
|
||||||
// 创建图片信息管理表
|
// 创建图片信息管理表
|
||||||
system.CreatePictureTable()
|
system.CreateFileTable()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ func FilmSourceInit() {
|
|||||||
}
|
}
|
||||||
var l []system.FilmSource = []system.FilmSource{
|
var l []system.FilmSource = []system.FilmSource{
|
||||||
{Id: util.GenerateSalt(), Name: "HD(lzBk)", Uri: `https://cj.lzcaiji.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
{Id: util.GenerateSalt(), Name: "HD(lzBk)", Uri: `https://cj.lzcaiji.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||||
{Id: util.GenerateSalt(), Name: "HD(sn)", Uri: `https://suoniapi.com/api.php/provide/vod/from/snm3u8/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
{Id: util.GenerateSalt(), Name: "HD(sn)", Uri: `https://suoniapi.com/api.php/provide/vod/from/snm3u8/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2000},
|
||||||
{Id: util.GenerateSalt(), Name: "HD(bf)", Uri: `https://bfzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 1600},
|
{Id: util.GenerateSalt(), Name: "HD(bf)", Uri: `https://bfzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2500},
|
||||||
{Id: util.GenerateSalt(), Name: "HD(ff)", Uri: `http://cj.ffzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
{Id: util.GenerateSalt(), Name: "HD(ff)", Uri: `http://cj.ffzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||||
{Id: util.GenerateSalt(), Name: "HD(kk)", Uri: `https://kuaikan-api.com/api.php/provide/vod/from/kuaikan/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
{Id: util.GenerateSalt(), Name: "HD(kk)", Uri: `https://kuaikan-api.com/api.php/provide/vod/from/kuaikan/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||||
//{Id: util.GenerateSalt(), Name: "HD(lz)", Uri: `https://cj.lziapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
//{Id: util.GenerateSalt(), Name: "HD(lz)", Uri: `https://cj.lziapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||||
|
|||||||
@@ -51,3 +51,8 @@ func CreateBaseDir() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveFile(path string) error {
|
||||||
|
err := os.Remove(path)
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ func InitMysql() (err error) {
|
|||||||
SingularTable: true, //是否使用 结构体名称作为表名 (关闭自动变复数)
|
SingularTable: true, //是否使用 结构体名称作为表名 (关闭自动变复数)
|
||||||
//NameReplacer: strings.NewReplacer("spider_", ""), // 替表名和字段中的 Me 为 空
|
//NameReplacer: strings.NewReplacer("spider_", ""), // 替表名和字段中的 Me 为 空
|
||||||
},
|
},
|
||||||
// Logger: logger.Default.LogMode(logger.Info), //设置日志级别为Info
|
//Logger: logger.Default.LogMode(logger.Info), //设置日志级别为Info
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,10 +201,17 @@ func BatchCollect(h int, ids ...string) {
|
|||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
// 如果查询到对应Id的资源站信息, 且资源站处于启用状态
|
// 如果查询到对应Id的资源站信息, 且资源站处于启用状态
|
||||||
if fs := system.FindCollectSourceById(id); fs != nil && fs.State {
|
if fs := system.FindCollectSourceById(id); fs != nil && fs.State {
|
||||||
|
// 采用协程并发执行, 每个站点单独开启一个协程执行
|
||||||
|
go func() {
|
||||||
|
err := HandleCollect(fs.Id, h)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
// 执行当前站点的采集任务
|
// 执行当前站点的采集任务
|
||||||
if err := HandleCollect(fs.Id, h); err != nil {
|
//if err := HandleCollect(fs.Id, h); err != nil {
|
||||||
log.Println(err)
|
// log.Println(err)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ func SetupRouter() *gin.Engine {
|
|||||||
fileRoute := manageRoute.Group(`/file`)
|
fileRoute := manageRoute.Group(`/file`)
|
||||||
{
|
{
|
||||||
fileRoute.POST(`/upload`, controller.SingleUpload)
|
fileRoute.POST(`/upload`, controller.SingleUpload)
|
||||||
|
fileRoute.GET(`/upload/multiple`, controller.MultipleUpload)
|
||||||
|
fileRoute.GET(`/del`, controller.DelFile)
|
||||||
fileRoute.GET(`/list`, controller.PhotoWall)
|
fileRoute.GET(`/list`, controller.PhotoWall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,20 +15,6 @@ const (
|
|||||||
// MAXGoroutine max goroutine, 执行spider中对协程的数量限制
|
// MAXGoroutine max goroutine, 执行spider中对协程的数量限制
|
||||||
MAXGoroutine = 10
|
MAXGoroutine = 10
|
||||||
|
|
||||||
// CornMovieUpdate 影片更新定时任务间隔
|
|
||||||
CornMovieUpdate = "0 0/20 * * * ?"
|
|
||||||
// UpdateInterval 获取最近几小时更新的影片 (h 小时) 默认3小时
|
|
||||||
UpdateInterval = "3"
|
|
||||||
// CornUpdateAll 每月28执行一次清库更新
|
|
||||||
CornUpdateAll = "0 0 2 28 * ?"
|
|
||||||
|
|
||||||
// SpiderCipher 设置Spider触发指令的验证
|
|
||||||
SpiderCipher = "Life in a different world from zero"
|
|
||||||
|
|
||||||
// ImgCacheFlag 是否开启将主站影片图片放入本地进行存储
|
|
||||||
ImgCacheFlag = false
|
|
||||||
//ImageDir = "./resource/static/images"
|
|
||||||
|
|
||||||
FilmPictureUploadDir = "./static/upload/gallery"
|
FilmPictureUploadDir = "./static/upload/gallery"
|
||||||
FilmPictureUrlPath = "/upload/pic/poster/"
|
FilmPictureUrlPath = "/upload/pic/poster/"
|
||||||
FilmPictureAccess = "/api/upload/pic/poster/"
|
FilmPictureAccess = "/api/upload/pic/poster/"
|
||||||
@@ -62,15 +48,6 @@ const (
|
|||||||
VirtualPictureKey = "VirtualPicture"
|
VirtualPictureKey = "VirtualPicture"
|
||||||
// MaxScanCount redis Scan 操作每次扫描的数据量, 每次最多扫描300条数据
|
// MaxScanCount redis Scan 操作每次扫描的数据量, 每次最多扫描300条数据
|
||||||
MaxScanCount = 300
|
MaxScanCount = 300
|
||||||
|
|
||||||
// SearchCount Search scan 识别范围
|
|
||||||
SearchCount = 3000
|
|
||||||
// SearchKeys Search Key Hash
|
|
||||||
SearchKeys = "SearchKeys"
|
|
||||||
// SearchScoreListKey 根据评分检索的key
|
|
||||||
SearchScoreListKey = "Search:SearchScoreList"
|
|
||||||
SearchTimeListKey = "Search:SearchTimeList"
|
|
||||||
SearchHeatListKey = "Search:SearchHeatList"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -106,7 +83,7 @@ const (
|
|||||||
SearchTableName = "search"
|
SearchTableName = "search"
|
||||||
UserTableName = "users"
|
UserTableName = "users"
|
||||||
UserIdInitialVal = 10000
|
UserIdInitialVal = 10000
|
||||||
PictureTableName = "picture"
|
FileTableName = "files"
|
||||||
|
|
||||||
//mysql服务配置信息 root:root 设置mysql账户的用户名和密码
|
//mysql服务配置信息 root:root 设置mysql账户的用户名和密码
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"server/logic"
|
"server/logic"
|
||||||
"server/model/system"
|
"server/model/system"
|
||||||
"server/plugin/common/util"
|
"server/plugin/common/util"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SingleUpload 单文件上传, 暂定为图片上传
|
// SingleUpload 单文件上传, 暂定为图片上传
|
||||||
@@ -24,13 +25,6 @@ func SingleUpload(c *gin.Context) {
|
|||||||
system.Failed(err.Error(), c)
|
system.Failed(err.Error(), c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 创建文件保存路径, 如果不存在则创建
|
|
||||||
//if _, err = os.Stat(config.ImageDir); os.IsNotExist(err) {
|
|
||||||
// err = os.MkdirAll(config.ImageDir, os.ModePerm)
|
|
||||||
// if err != nil {
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// 生成文件名, 保存文件到服务器
|
// 生成文件名, 保存文件到服务器
|
||||||
fileName := fmt.Sprintf("%s/%s%s", config.FilmPictureUploadDir, util.RandomString(8), filepath.Ext(file.Filename))
|
fileName := fmt.Sprintf("%s/%s%s", config.FilmPictureUploadDir, util.RandomString(8), filepath.Ext(file.Filename))
|
||||||
@@ -48,12 +42,68 @@ func SingleUpload(c *gin.Context) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MultipleUpload 批量文件上传
|
||||||
|
func MultipleUpload(c *gin.Context) {
|
||||||
|
// 获取执行操作的用户信息
|
||||||
|
v, ok := c.Get(config.AuthUserClaims)
|
||||||
|
if !ok {
|
||||||
|
system.Failed("上传失败, 当前用户信息异常", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 解析表单数据
|
||||||
|
form, err := c.MultipartForm()
|
||||||
|
if err != nil {
|
||||||
|
system.Failed(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 获取文件列表
|
||||||
|
files := form.File["files"]
|
||||||
|
|
||||||
|
// 解析当前登录的用户信息
|
||||||
|
uc := v.(*system.UserClaims)
|
||||||
|
|
||||||
|
// 遍历文件列表
|
||||||
|
var fileNames []string
|
||||||
|
for _, file := range files {
|
||||||
|
// 生成文件名, 保存文件到服务器
|
||||||
|
fileName := fmt.Sprintf("%s/%s%s", config.FilmPictureUploadDir, util.RandomString(8), filepath.Ext(file.Filename))
|
||||||
|
err = c.SaveUploadedFile(file, fileName)
|
||||||
|
if err != nil {
|
||||||
|
system.Failed(err.Error(), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 记录图片信息到系统表中, 并获取返回的图片访问路径
|
||||||
|
fileNames = append(fileNames, logic.FileL.SingleFileUpload(fileName, int(uc.UserID)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回图片访问地址以及成功的响应
|
||||||
|
system.Success(fileNames, "上传成功", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelFile 删除文件
|
||||||
|
func DelFile(c *gin.Context) {
|
||||||
|
id, err := strconv.ParseUint(c.DefaultQuery("id", ""), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
system.Failed("操作失败, 未获取到需删除的文件标识信息", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if e := logic.FileL.RemoveFileById(uint(id)); e != nil {
|
||||||
|
system.Failed(fmt.Sprint("删除失败", e.Error()), c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
system.SuccessOnlyMsg("文件已删除", c)
|
||||||
|
}
|
||||||
|
|
||||||
// PhotoWall 照片墙数据
|
// PhotoWall 照片墙数据
|
||||||
func PhotoWall(c *gin.Context) {
|
func PhotoWall(c *gin.Context) {
|
||||||
|
current, err := strconv.Atoi(c.DefaultQuery("current", "1"))
|
||||||
|
if err != nil {
|
||||||
|
system.Failed("图片分页数据获取失败, 分页参数异常", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
// 获取系统保存的文件的图片分页数据
|
// 获取系统保存的文件的图片分页数据
|
||||||
page := system.Page{PageSize: 10, Current: 1}
|
page := system.Page{PageSize: 39, Current: current}
|
||||||
// 获取分页数据
|
// 获取分页数据
|
||||||
pl := logic.FileL.GetPhotoPage(&page)
|
pl := logic.FileL.GetPhotoPage(&page)
|
||||||
system.Success(pl, "图片分页数据获取成功", c)
|
system.Success(gin.H{"list": pl, "page": page}, "图片分页数据获取成功", c)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ func FilmPlayInfo(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
// 获取影片详情信息
|
// 获取影片详情信息
|
||||||
detail := logic.IL.GetFilmDetail(id)
|
detail := logic.IL.GetFilmDetail(id)
|
||||||
|
// 如果 playFrom 为空, 则设置默认播放源和默认影片数据
|
||||||
|
if len(playFrom) <= 1 && len(detail.List) > 0 {
|
||||||
|
playFrom = detail.List[0].Id
|
||||||
|
|
||||||
|
}
|
||||||
// 获取当前影片播放信息
|
// 获取当前影片播放信息
|
||||||
var currentPlay system.MovieUrlInfo
|
var currentPlay system.MovieUrlInfo
|
||||||
for _, v := range detail.List {
|
for _, v := range detail.List {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"server/config"
|
"server/config"
|
||||||
"server/model/system"
|
"server/model/system"
|
||||||
|
"server/plugin/common/util"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,15 +16,31 @@ var FileL FileLogic
|
|||||||
|
|
||||||
func (fl *FileLogic) SingleFileUpload(fileName string, uid int) string {
|
func (fl *FileLogic) SingleFileUpload(fileName string, uid int) string {
|
||||||
// 生成图片信息
|
// 生成图片信息
|
||||||
var p = system.Picture{Link: fmt.Sprint(config.FilmPictureAccess, filepath.Base(fileName)), Uid: uid, PicType: 0}
|
var f = system.FileInfo{Link: fmt.Sprint(config.FilmPictureAccess, filepath.Base(fileName)), Uid: uid, Type: 0}
|
||||||
p.PicUid = strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
|
f.Fid = strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
|
||||||
|
f.FileType = strings.TrimPrefix(filepath.Ext(fileName), ".")
|
||||||
// 记录图片信息到系统表中
|
// 记录图片信息到系统表中
|
||||||
system.SaveGallery(p)
|
system.SaveGallery(f)
|
||||||
return p.Link
|
return f.Link
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPhotoPage 获取系统内的图片分页信息
|
// GetPhotoPage 获取系统内的图片分页信息
|
||||||
func (fl *FileLogic) GetPhotoPage(page *system.Page) []system.Picture {
|
func (fl *FileLogic) GetPhotoPage(page *system.Page) []system.FileInfo {
|
||||||
return system.GetPicturePage(page)
|
// 设置必要参数
|
||||||
|
var tl = []string{"jpeg", "jpg", "png", "webp"}
|
||||||
|
return system.GetFileInfoPage(tl, page)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveFileById 删除文件信息
|
||||||
|
func (fl *FileLogic) RemoveFileById(id uint) error {
|
||||||
|
// 首先获取对应图片信息
|
||||||
|
f := system.GetFileInfoById(id)
|
||||||
|
// 通过f删除本地图片
|
||||||
|
err := util.RemoveFile(f.StoragePath())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
// 删除图片的关联信息
|
||||||
|
system.DelFileInfo(id)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ var IL *IndexLogic
|
|||||||
|
|
||||||
// IndexPage 首页数据处理
|
// IndexPage 首页数据处理
|
||||||
func (i *IndexLogic) IndexPage() map[string]interface{} {
|
func (i *IndexLogic) IndexPage() map[string]interface{} {
|
||||||
//声明返回值
|
|
||||||
//Info := make(map[string]interface{})
|
|
||||||
// 首页请求时长较高, 采用redis进行缓存, 在定时任务更新影片时清除对应缓存
|
// 首页请求时长较高, 采用redis进行缓存, 在定时任务更新影片时清除对应缓存
|
||||||
// 判断是否存在缓存数据, 存在则直接将数据返回
|
// 判断是否存在缓存数据, 存在则直接将数据返回
|
||||||
Info := system.GetCacheData(config.IndexCacheKey)
|
Info := system.GetCacheData(config.IndexCacheKey)
|
||||||
@@ -34,21 +32,14 @@ func (i *IndexLogic) IndexPage() map[string]interface{} {
|
|||||||
// 1. 首页分类数据处理 导航分类数据处理, 只提供 电影 电视剧 综艺 动漫 四大顶级分类和其子分类
|
// 1. 首页分类数据处理 导航分类数据处理, 只提供 电影 电视剧 综艺 动漫 四大顶级分类和其子分类
|
||||||
tree := system.CategoryTree{Category: &system.Category{Id: 0, Name: "分类信息"}}
|
tree := system.CategoryTree{Category: &system.Category{Id: 0, Name: "分类信息"}}
|
||||||
sysTree := system.GetCategoryTree()
|
sysTree := system.GetCategoryTree()
|
||||||
// 由于采集源数据格式不一,因此采用名称匹配
|
// 只展示show=true的分页影片信息
|
||||||
//for _, c := range sysTree.Children {
|
|
||||||
// switch c.Category.Name {
|
|
||||||
// case "电影", "电影片", "连续剧", "电视剧", "综艺", "综艺片", "动漫", "动漫片":
|
|
||||||
// tree.Children = append(tree.Children, c)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
for _, c := range sysTree.Children {
|
for _, c := range sysTree.Children {
|
||||||
// 只针对一级分类进行处理
|
// 只针对一级分类进行处理
|
||||||
if c.Show {
|
if c.Show {
|
||||||
tree.Children = append(tree.Children, c)
|
tree.Children = append(tree.Children, c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 返回分类信息
|
||||||
Info["category"] = tree
|
Info["category"] = tree
|
||||||
// 2. 提供用于首页展示的顶级分类影片信息, 每分类 14条数据
|
// 2. 提供用于首页展示的顶级分类影片信息, 每分类 14条数据
|
||||||
var list []map[string]interface{}
|
var list []map[string]interface{}
|
||||||
@@ -62,7 +53,7 @@ func (i *IndexLogic) IndexPage() map[string]interface{} {
|
|||||||
}
|
}
|
||||||
Info["content"] = list
|
Info["content"] = list
|
||||||
// 不存在首页数据缓存时将查询数据缓存到redis中
|
// 不存在首页数据缓存时将查询数据缓存到redis中
|
||||||
//system.DataCache(config.IndexCacheKey, Info)
|
system.DataCache(config.IndexCacheKey, Info)
|
||||||
return Info
|
return Info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,21 +6,24 @@ import (
|
|||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"log"
|
"log"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"server/config"
|
"server/config"
|
||||||
"server/plugin/common/util"
|
"server/plugin/common/util"
|
||||||
"server/plugin/db"
|
"server/plugin/db"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Picture 图片信息对象
|
// FileInfo 图片信息对象
|
||||||
type Picture struct {
|
type FileInfo struct {
|
||||||
gorm.Model
|
gorm.Model
|
||||||
Link string `json:"link"` // 图片链接
|
Link string `json:"link"` // 图片链接
|
||||||
Uid int `json:"uid"` // 上传人ID
|
Uid int `json:"uid"` // 上传人ID
|
||||||
RelevanceId int64 `json:"relevanceId"` // 关联资源ID
|
RelevanceId int64 `json:"relevanceId"` // 关联资源ID
|
||||||
PicType int `json:"picType"` // 图片类型 (0 影片封面, 1 用户头像)
|
Type int `json:"type"` // 文件类型 (0 影片封面, 1 用户头像)
|
||||||
PicUid string `json:"picUid"` // 图片唯一标识, 通常为文件名
|
Fid string `json:"fid"` // 图片唯一标识, 通常为文件名
|
||||||
//Size int `json:"size"` // 图片大小
|
FileType string `json:"fileType"` // 文件类型, txt, png, jpg
|
||||||
|
//Size int `json:"size"` // 文件大小
|
||||||
}
|
}
|
||||||
|
|
||||||
// VirtualPicture 采集入站,待同步的图片信息
|
// VirtualPicture 采集入站,待同步的图片信息
|
||||||
@@ -32,57 +35,80 @@ type VirtualPicture struct {
|
|||||||
//------------------------------------------------本地图库------------------------------------------------
|
//------------------------------------------------本地图库------------------------------------------------
|
||||||
|
|
||||||
// TableName 设置图片存储表的表名
|
// TableName 设置图片存储表的表名
|
||||||
func (p *Picture) TableName() string {
|
func (f *FileInfo) TableName() string {
|
||||||
return config.PictureTableName
|
return config.FileTableName
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatePictureTable 创建图片关联信息存储表
|
// StoragePath 获取文件的保存路径
|
||||||
func CreatePictureTable() {
|
func (f *FileInfo) StoragePath() string {
|
||||||
|
var storage string
|
||||||
|
switch f.FileType {
|
||||||
|
case "jpeg", "jpg", "png", "webp":
|
||||||
|
storage = strings.Replace(f.Link, config.FilmPictureAccess, fmt.Sprint(config.FilmPictureUploadDir, "/"), 1)
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
return storage
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateFileTable 创建图片关联信息存储表
|
||||||
|
func CreateFileTable() {
|
||||||
// 如果不存在则创建表 并设置自增ID初始值为10000
|
// 如果不存在则创建表 并设置自增ID初始值为10000
|
||||||
if !ExistPictureTable() {
|
if !ExistFileTable() {
|
||||||
err := db.Mdb.AutoMigrate(&Picture{})
|
err := db.Mdb.AutoMigrate(&FileInfo{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Create Table Picture Failed: ", err)
|
log.Println("Create Table FileInfo Failed: ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExistPictureTable 是否存在Picture表
|
// ExistFileTable 是否存在Picture表
|
||||||
func ExistPictureTable() bool {
|
func ExistFileTable() bool {
|
||||||
// 1. 判断表中是否存在当前表
|
// 1. 判断表中是否存在当前表
|
||||||
return db.Mdb.Migrator().HasTable(&Picture{})
|
return db.Mdb.Migrator().HasTable(&FileInfo{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SaveGallery 保存图片关联信息
|
// SaveGallery 保存图片关联信息
|
||||||
func SaveGallery(p Picture) {
|
func SaveGallery(f FileInfo) {
|
||||||
db.Mdb.Create(&p)
|
db.Mdb.Create(&f)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExistPictureByRid 查找图片信息是否存在
|
// ExistFileInfoByRid 查找图片信息是否存在
|
||||||
func ExistPictureByRid(rid int64) bool {
|
func ExistFileInfoByRid(rid int64) bool {
|
||||||
var count int64
|
var count int64
|
||||||
db.Mdb.Model(&Picture{}).Where("relevance_id = ?", rid).Count(&count)
|
db.Mdb.Model(&FileInfo{}).Where("relevance_id = ?", rid).Count(&count)
|
||||||
return count > 0
|
return count > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPictureByRid 通过关联的资源id获取对应的图片信息
|
// GetFileInfoByRid 通过关联的资源id获取对应的图片信息
|
||||||
func GetPictureByRid(rid int64) Picture {
|
func GetFileInfoByRid(rid int64) FileInfo {
|
||||||
var p Picture
|
var f FileInfo
|
||||||
db.Mdb.Where("relevance_id = ?", rid).First(&p)
|
db.Mdb.Where("relevance_id = ?", rid).First(&f)
|
||||||
return p
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPicturePage(page *Page) []Picture {
|
// GetFileInfoById 通过ID获取对应的图片信息
|
||||||
var pl []Picture
|
func GetFileInfoById(id uint) FileInfo {
|
||||||
query := db.Mdb.Model(&Picture{})
|
var f = FileInfo{}
|
||||||
|
db.Mdb.First(&f, id)
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFileInfoPage 获取文件关联信息分页数据
|
||||||
|
func GetFileInfoPage(tl []string, page *Page) []FileInfo {
|
||||||
|
var fl []FileInfo
|
||||||
|
query := db.Mdb.Model(&FileInfo{}).Where("file_type IN ?", tl).Order("id DESC")
|
||||||
// 获取分页相关参数
|
// 获取分页相关参数
|
||||||
GetPage(query, page)
|
GetPage(query, page)
|
||||||
// 获取分页数据
|
// 获取分页数据
|
||||||
if err := query.Limit(page.PageSize).Offset((page.Current - 1) * page.PageSize).Find(&pl).Error; err != nil {
|
if err := query.Limit(page.PageSize).Offset((page.Current - 1) * page.PageSize).Find(&fl).Error; err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return pl
|
return fl
|
||||||
|
}
|
||||||
|
|
||||||
|
func DelFileInfo(id uint) {
|
||||||
|
db.Mdb.Unscoped().Delete(&FileInfo{}, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------图片同步------------------------------------------------
|
//------------------------------------------------图片同步------------------------------------------------
|
||||||
@@ -123,7 +149,7 @@ func SyncFilmPicture() {
|
|||||||
vp := VirtualPicture{}
|
vp := VirtualPicture{}
|
||||||
_ = json.Unmarshal([]byte(s.Member.(string)), &vp)
|
_ = json.Unmarshal([]byte(s.Member.(string)), &vp)
|
||||||
// 判断当前影片是否已经同步过图片, 如果已经同步则直接跳过后续逻辑
|
// 判断当前影片是否已经同步过图片, 如果已经同步则直接跳过后续逻辑
|
||||||
if ExistPictureByRid(vp.Id) {
|
if ExistFileInfoByRid(vp.Id) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 将图片同步到服务器中
|
// 将图片同步到服务器中
|
||||||
@@ -132,12 +158,13 @@ func SyncFilmPicture() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// 完成同步后将图片信息保存到 Gallery 中
|
// 完成同步后将图片信息保存到 Gallery 中
|
||||||
SaveGallery(Picture{
|
SaveGallery(FileInfo{
|
||||||
Link: fmt.Sprint(config.FilmPictureAccess, fileName),
|
Link: fmt.Sprint(config.FilmPictureAccess, fileName),
|
||||||
Uid: config.UserIdInitialVal,
|
Uid: config.UserIdInitialVal,
|
||||||
RelevanceId: vp.Id,
|
RelevanceId: vp.Id,
|
||||||
PicType: 0,
|
Type: 0,
|
||||||
PicUid: regexp.MustCompile(`\.[^.]+$`).ReplaceAllString(fileName, ""),
|
Fid: regexp.MustCompile(`\.[^.]+$`).ReplaceAllString(fileName, ""),
|
||||||
|
FileType: strings.TrimPrefix(filepath.Ext(fileName), "."),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 递归执行直到图片暂存信息为空
|
// 递归执行直到图片暂存信息为空
|
||||||
@@ -147,21 +174,21 @@ func SyncFilmPicture() {
|
|||||||
// ReplaceDetailPic 将影片详情中的图片地址替换为自己的
|
// ReplaceDetailPic 将影片详情中的图片地址替换为自己的
|
||||||
func ReplaceDetailPic(d *MovieDetail) {
|
func ReplaceDetailPic(d *MovieDetail) {
|
||||||
// 查询影片对应的本地图片信息
|
// 查询影片对应的本地图片信息
|
||||||
if ExistPictureByRid(d.Id) {
|
if ExistFileInfoByRid(d.Id) {
|
||||||
// 如果存在关联的本地图片, 则查询对应的图片信息
|
// 如果存在关联的本地图片, 则查询对应的图片信息
|
||||||
p := GetPictureByRid(d.Id)
|
f := GetFileInfoByRid(d.Id)
|
||||||
// 替换采集站的图片链接为本地链接
|
// 替换采集站的图片链接为本地链接
|
||||||
d.Picture = p.Link
|
d.Picture = f.Link
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReplaceBasicDetailPic 替换影片基本数据中的封面图为本地图片
|
// ReplaceBasicDetailPic 替换影片基本数据中的封面图为本地图片
|
||||||
func ReplaceBasicDetailPic(d *MovieBasicInfo) {
|
func ReplaceBasicDetailPic(d *MovieBasicInfo) {
|
||||||
// 查询影片对应的本地图片信息
|
// 查询影片对应的本地图片信息
|
||||||
if ExistPictureByRid(d.Id) {
|
if ExistFileInfoByRid(d.Id) {
|
||||||
// 如果存在关联的本地图片, 则查询对应的图片信息
|
// 如果存在关联的本地图片, 则查询对应的图片信息
|
||||||
p := GetPictureByRid(d.Id)
|
f := GetFileInfoByRid(d.Id)
|
||||||
// 替换采集站的图片链接为本地链接
|
// 替换采集站的图片链接为本地链接
|
||||||
d.Picture = p.Link
|
d.Picture = f.Link
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -640,10 +640,10 @@ func GetSearchInfosByTags(st SearchTagsVO, page *Page) []SearchInfo {
|
|||||||
qw = qw.Where("class_tag LIKE ?", fmt.Sprintf("%%%v%%", value))
|
qw = qw.Where("class_tag LIKE ?", fmt.Sprintf("%%%v%%", value))
|
||||||
case "sort":
|
case "sort":
|
||||||
if strings.EqualFold(value.(string), "release_stamp") {
|
if strings.EqualFold(value.(string), "release_stamp") {
|
||||||
qw.Order(fmt.Sprintf("year DESC ,%v Desc", value))
|
qw.Order(fmt.Sprintf("year DESC ,%v DESC", value))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
qw.Order(fmt.Sprintf("%v Desc", value))
|
qw.Order(fmt.Sprintf("%v DESC", value))
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ func TableInIt() {
|
|||||||
// 创建 Search Table
|
// 创建 Search Table
|
||||||
system.CreateSearchTable()
|
system.CreateSearchTable()
|
||||||
// 创建图片信息管理表
|
// 创建图片信息管理表
|
||||||
system.CreatePictureTable()
|
system.CreateFileTable()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ func FilmSourceInit() {
|
|||||||
}
|
}
|
||||||
var l []system.FilmSource = []system.FilmSource{
|
var l []system.FilmSource = []system.FilmSource{
|
||||||
{Id: util.GenerateSalt(), Name: "HD(lzBk)", Uri: `https://cj.lzcaiji.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
{Id: util.GenerateSalt(), Name: "HD(lzBk)", Uri: `https://cj.lzcaiji.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||||
{Id: util.GenerateSalt(), Name: "HD(sn)", Uri: `https://suoniapi.com/api.php/provide/vod/from/snm3u8/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
{Id: util.GenerateSalt(), Name: "HD(sn)", Uri: `https://suoniapi.com/api.php/provide/vod/from/snm3u8/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2000},
|
||||||
{Id: util.GenerateSalt(), Name: "HD(bf)", Uri: `https://bfzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 1600},
|
{Id: util.GenerateSalt(), Name: "HD(bf)", Uri: `https://bfzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2500},
|
||||||
{Id: util.GenerateSalt(), Name: "HD(ff)", Uri: `http://cj.ffzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
{Id: util.GenerateSalt(), Name: "HD(ff)", Uri: `http://cj.ffzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||||
{Id: util.GenerateSalt(), Name: "HD(kk)", Uri: `https://kuaikan-api.com/api.php/provide/vod/from/kuaikan/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
{Id: util.GenerateSalt(), Name: "HD(kk)", Uri: `https://kuaikan-api.com/api.php/provide/vod/from/kuaikan/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||||
//{Id: util.GenerateSalt(), Name: "HD(lz)", Uri: `https://cj.lziapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
//{Id: util.GenerateSalt(), Name: "HD(lz)", Uri: `https://cj.lziapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true},
|
||||||
|
|||||||
@@ -51,3 +51,8 @@ func CreateBaseDir() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveFile(path string) error {
|
||||||
|
err := os.Remove(path)
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -201,10 +201,17 @@ func BatchCollect(h int, ids ...string) {
|
|||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
// 如果查询到对应Id的资源站信息, 且资源站处于启用状态
|
// 如果查询到对应Id的资源站信息, 且资源站处于启用状态
|
||||||
if fs := system.FindCollectSourceById(id); fs != nil && fs.State {
|
if fs := system.FindCollectSourceById(id); fs != nil && fs.State {
|
||||||
|
// 采用协程并发执行, 每个站点单独开启一个协程执行
|
||||||
|
go func() {
|
||||||
|
err := HandleCollect(fs.Id, h)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
// 执行当前站点的采集任务
|
// 执行当前站点的采集任务
|
||||||
if err := HandleCollect(fs.Id, h); err != nil {
|
//if err := HandleCollect(fs.Id, h); err != nil {
|
||||||
log.Println(err)
|
// log.Println(err)
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ func SetupRouter() *gin.Engine {
|
|||||||
fileRoute := manageRoute.Group(`/file`)
|
fileRoute := manageRoute.Group(`/file`)
|
||||||
{
|
{
|
||||||
fileRoute.POST(`/upload`, controller.SingleUpload)
|
fileRoute.POST(`/upload`, controller.SingleUpload)
|
||||||
|
fileRoute.GET(`/upload/multiple`, controller.MultipleUpload)
|
||||||
|
fileRoute.GET(`/del`, controller.DelFile)
|
||||||
fileRoute.GET(`/list`, controller.PhotoWall)
|
fileRoute.GET(`/list`, controller.PhotoWall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user