package web import ( "fmt" "videoweb/app/service/playletser" "github.com/gin-gonic/gin" ) // List 短剧列表页:题材 + GET /api/app/playlet/all/list。 // 文档:http://172.104.181.99:25319/swagger/index.html#/app短剧相关接口/get_api_app_playlet_all_list func List(c *gin.Context) { q := playletser.ParseAllListQuery(c) themes := playletser.FetchThemesOrEmpty(c, 0) playletser.ResolveAllListTheme(&q, themes) themeResolved := listThemeResolved(q, themes) raw := playletser.FetchAllListOrEmpty(c, q) pageHeading, seoSelections := listSEOContext(q, themes) title := pageHeading + " - 黄果短剧" if raw != nil && raw.SeoInfo.Title != "" { title = raw.SeoInfo.Title } list := []playletser.CommonData(nil) total := int64(0) pageNum, pageSize := q.PageNum, q.PageSize var seo playletser.SeoInfo var advitise any if raw != nil { list = raw.List total = raw.TotalCount seo = raw.SeoInfo if raw.PageNum > 0 { pageNum = raw.PageNum } if raw.PageSize > 0 { pageSize = raw.PageSize } advitise = raw.Advitise } HTMLOK(c, "list.html", gin.H{ "title": title, "navActive": "list", "seoInfo": seo, "seoSelections": seoSelections, "pageHeading": pageHeading, "list": list, "totalCount": total, "pageNum": pageNum, "pageSize": pageSize, "listCount": fmt.Sprintf("共 %d 部", total), "advitise": advitise, "themeList": themes, "themeSlug": q.ThemeSlug, "themeId": q.ThemeID, "updateStatus": q.UpdateStatus, "sortType": q.SortType, "seoEntityValid": themeResolved || total > 0, "pagination": playletser.BuildAllListPagination(q, total), "canonicalPath": q.URL(), }) } func listThemeResolved(q playletser.AllListQuery, themes []playletser.PlayletThemeItem) bool { if q.ThemeID <= 0 && q.ThemeSlug == "" { return true } for _, theme := range themes { if (q.ThemeID > 0 && theme.ID == q.ThemeID) || (q.ThemeSlug != "" && theme.Slug == q.ThemeSlug) { return true } } return false } func listSEOContext(q playletser.AllListQuery, themes []playletser.PlayletThemeItem) (string, []playletser.SEOSelection) { heading := "全部短剧" selections := make([]playletser.SEOSelection, 0, 3) themeName := q.ThemeSlug for _, theme := range themes { if (q.ThemeID > 0 && theme.ID == q.ThemeID) || (q.ThemeSlug != "" && theme.Slug == q.ThemeSlug) { themeName = theme.Name break } } if themeName != "" { heading = themeName + "短剧" selections = append(selections, playletser.SEOSelection{Dimension: "题材", Value: themeName}) } if q.UpdateStatus == 1 { selections = append(selections, playletser.SEOSelection{Dimension: "状态", Value: "连载中"}) } else if q.UpdateStatus == 2 { selections = append(selections, playletser.SEOSelection{Dimension: "状态", Value: "已完结"}) } if q.SortType == 2 { selections = append(selections, playletser.SEOSelection{Dimension: "排序", Value: "最热"}) } else if q.SortType == 3 { selections = append(selections, playletser.SEOSelection{Dimension: "排序", Value: "收藏最多"}) } return heading, selections }