pc tag search finish

This commit is contained in:
mubai
2023-07-08 00:10:58 +08:00
parent 92a853a196
commit 21e1a00bd4
17 changed files with 630 additions and 42 deletions

View File

@@ -232,6 +232,18 @@ func GetDetailByKey(key string) MovieDetail {
return detail
}
// GetBasicInfoBySearchInfos 通过searchInfo 获取影片的基本信息
func GetBasicInfoBySearchInfos(infos ...SearchInfo) []MovieBasicInfo {
var list []MovieBasicInfo
for _, s := range infos {
data := []byte(db.Rdb.Get(db.Cxt, fmt.Sprintf(config.MovieBasicInfoKey, s.Cid, s.Mid)).Val())
basic := MovieBasicInfo{}
_ = json.Unmarshal(data, &basic)
list = append(list, basic)
}
return list
}
/*
对附属播放源入库时的name|dbID进行处理,保证唯一性
1. 去除name中的所有空格

View File

@@ -310,6 +310,14 @@ func TunCateSearchTable() {
}
}
// GetPage 获取分页相关数据
func GetPage(db *gorm.DB, page *Page) {
var count int64
db.Count(&count)
page.Total = int(count)
page.PageCount = int((page.Total + page.PageSize - 1) / page.PageSize)
}
// ================================= API 数据接口信息处理 =================================
// GetMovieListByPid 通过Pid 分类ID 获取对应影片的数据信息
@@ -563,11 +571,28 @@ func GetSearchInfosByTags(st SearchTagsVO, page *Page) []SearchInfo {
}
func GetPage(db *gorm.DB, page *Page) {
var count int64
db.Count(&count)
page.Total = int(count)
page.PageCount = int((page.Total + page.PageSize - 1) / page.PageSize)
// GetMovieListBySort 通过排序类型返回对应的影片基本信息
func GetMovieListBySort(t int, pid int64, page *Page) []MovieBasicInfo {
var sl []SearchInfo
qw := db.Mdb.Model(&SearchInfo{}).Where("pid", pid).Limit(page.PageSize).Offset((page.Current) - 10*page.PageSize)
// 针对不同排序类型返回对应的分页数据
switch t {
case 0:
// 最新上映 (上映时间)
qw.Order("year DESC, release_date DESC")
case 1:
// 排行榜 (暂定为热度排行)
qw.Order("year DESC, hits DESC")
case 2:
// 最近更新 (更新时间)
qw.Order("year DESC, update_stamp DESC")
}
if err := qw.Find(&sl).Error; err != nil {
log.Println(err)
return nil
}
return GetBasicInfoBySearchInfos(sl...)
}
// ================================= 接口数据缓存 =================================