Files
web_huangguo2_h5/app/api/web/index.go
T
谢宇宁andClaude Opus 5.5 0fbdba5ccf Initial commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 11:47:47 +07:00

60 lines
1.8 KiB
Go

package web
import (
"videoweb/app/service/playletser"
"videoweb/app/service/videoser"
"github.com/gin-gonic/gin"
)
// Index 首页 SSR:拉取 GET /api/app/playlet/home,按接口字段注入模板。
// 接口文档:http://172.104.181.99:25319/swagger/index.html#/app短剧相关接口/get_api_app_playlet_home
// 继续观看:GET /api/app/playlet/history/list?pageNum=1&pageSize=6
// 热播榜:短剧 hot/rank/list;剧集 video/all/list sortType=最热
func Index(c *gin.Context) {
raw := playletser.FetchHomeOrEmpty(c)
title := "黄果短剧"
if raw != nil && raw.SeoInfo.Title != "" {
title = raw.SeoInfo.Title
}
history := playletser.FetchHistoryListOrEmpty(c, playletser.HistoryListQuery{PageNum: 1, PageSize: 6})
continueWatch := history.List
if len(continueWatch) > 6 {
continueWatch = continueWatch[:6]
}
hotPlaylets := playletser.FetchHotRankListOrEmpty(c, playletser.HotRankQuery{
PageNum: 1,
PageSize: 10,
RankType: 1,
}).List
if len(hotPlaylets) > 10 {
hotPlaylets = hotPlaylets[:10]
}
hotVideos := videoser.FetchVideoAllListOrEmpty(c, videoser.SeriesListQuery{
PageNum: 1,
PageSize: 10,
SortType: videoser.SortHeat,
MediaType: videoser.MediaAll,
}).List
if len(hotVideos) > 10 {
hotVideos = hotVideos[:10]
}
HTMLOK(c, "index.html", gin.H{
"title": title,
"navActive": "home",
"seoInfo": raw.SeoInfo,
"announcements": raw.Announcements,
"advitise": raw.Advitise,
"homeBannerData": playletser.ActiveHomeBanners(raw.HomeBannerData),
"homeConfigData": playletser.ActiveHomeConfigs(raw.HomeConfigData),
// GET /api/app/playlet/tag/options → list(已上架标签)
"tagOptions": playletser.FetchTagOptionsOrEmpty(c),
"continueWatch": continueWatch,
"hotRankPlaylets": hotPlaylets,
"hotRankVideos": hotVideos,
})
}