mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-03-02 09:24:41 +08:00
fix default playSource and update upload manage
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"path/filepath"
|
||||
"server/config"
|
||||
"server/model/system"
|
||||
"server/plugin/common/util"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -15,15 +16,31 @@ var FileL FileLogic
|
||||
|
||||
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}
|
||||
p.PicUid = strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
|
||||
var f = system.FileInfo{Link: fmt.Sprint(config.FilmPictureAccess, filepath.Base(fileName)), Uid: uid, Type: 0}
|
||||
f.Fid = strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
|
||||
f.FileType = strings.TrimPrefix(filepath.Ext(fileName), ".")
|
||||
// 记录图片信息到系统表中
|
||||
system.SaveGallery(p)
|
||||
return p.Link
|
||||
system.SaveGallery(f)
|
||||
return f.Link
|
||||
}
|
||||
|
||||
// GetPhotoPage 获取系统内的图片分页信息
|
||||
func (fl *FileLogic) GetPhotoPage(page *system.Page) []system.Picture {
|
||||
return system.GetPicturePage(page)
|
||||
|
||||
func (fl *FileLogic) GetPhotoPage(page *system.Page) []system.FileInfo {
|
||||
// 设置必要参数
|
||||
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 首页数据处理
|
||||
func (i *IndexLogic) IndexPage() map[string]interface{} {
|
||||
//声明返回值
|
||||
//Info := make(map[string]interface{})
|
||||
// 首页请求时长较高, 采用redis进行缓存, 在定时任务更新影片时清除对应缓存
|
||||
// 判断是否存在缓存数据, 存在则直接将数据返回
|
||||
Info := system.GetCacheData(config.IndexCacheKey)
|
||||
@@ -34,21 +32,14 @@ func (i *IndexLogic) IndexPage() map[string]interface{} {
|
||||
// 1. 首页分类数据处理 导航分类数据处理, 只提供 电影 电视剧 综艺 动漫 四大顶级分类和其子分类
|
||||
tree := system.CategoryTree{Category: &system.Category{Id: 0, Name: "分类信息"}}
|
||||
sysTree := system.GetCategoryTree()
|
||||
// 由于采集源数据格式不一,因此采用名称匹配
|
||||
//for _, c := range sysTree.Children {
|
||||
// switch c.Category.Name {
|
||||
// case "电影", "电影片", "连续剧", "电视剧", "综艺", "综艺片", "动漫", "动漫片":
|
||||
// tree.Children = append(tree.Children, c)
|
||||
// }
|
||||
//}
|
||||
|
||||
// 只展示show=true的分页影片信息
|
||||
for _, c := range sysTree.Children {
|
||||
// 只针对一级分类进行处理
|
||||
if c.Show {
|
||||
tree.Children = append(tree.Children, c)
|
||||
}
|
||||
}
|
||||
|
||||
// 返回分类信息
|
||||
Info["category"] = tree
|
||||
// 2. 提供用于首页展示的顶级分类影片信息, 每分类 14条数据
|
||||
var list []map[string]interface{}
|
||||
@@ -62,7 +53,7 @@ func (i *IndexLogic) IndexPage() map[string]interface{} {
|
||||
}
|
||||
Info["content"] = list
|
||||
// 不存在首页数据缓存时将查询数据缓存到redis中
|
||||
//system.DataCache(config.IndexCacheKey, Info)
|
||||
system.DataCache(config.IndexCacheKey, Info)
|
||||
return Info
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user