98 lines
2.5 KiB
Go
98 lines
2.5 KiB
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
"videoweb/app/service/playletser"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// TopicDetail 专题详情页:GET /api/app/playlet/topic/detail。
|
|
// 文档:http://172.104.181.99:25319/swagger/index.html#/app短剧相关接口/get_api_app_playlet_topic_detail
|
|
func TopicDetail(c *gin.Context) {
|
|
q := playletser.ParseTopicDetailQuery(c)
|
|
playletser.ResolveTopicDetailID(c, &q)
|
|
raw := playletser.FetchTopicDetailOrEmpty(c, q)
|
|
if raw != nil {
|
|
if raw.Slug != "" {
|
|
q.Slug = raw.Slug
|
|
}
|
|
if raw.ID > 0 {
|
|
q.ID = raw.ID
|
|
}
|
|
}
|
|
|
|
name := ""
|
|
if raw != nil {
|
|
name = raw.Name
|
|
}
|
|
title := "专题 - 黄果短剧"
|
|
if raw != nil && raw.SeoInfo.Title != "" {
|
|
title = raw.SeoInfo.Title
|
|
} else if name != "" {
|
|
title = name + " - 黄果短剧"
|
|
}
|
|
|
|
list := []playletser.CommonData(nil)
|
|
more := []playletser.PlayletTopicPageItem(nil)
|
|
total := int64(0)
|
|
playletCount := int64(0)
|
|
pageNum, pageSize := q.PageNum, q.PageSize
|
|
var seo playletser.SeoInfo
|
|
desc := ""
|
|
heroCover := ""
|
|
covers := []string(nil)
|
|
if raw != nil {
|
|
list = raw.List
|
|
more = raw.MoreTopics
|
|
total = raw.TotalCount
|
|
playletCount = raw.PlayletCount
|
|
seo = raw.SeoInfo
|
|
desc = raw.Desc
|
|
heroCover = playletser.TopicDetailHeroCover(*raw)
|
|
covers = playletser.TopicDetailCoverURLs(*raw)
|
|
if raw.PageNum > 0 {
|
|
pageNum = raw.PageNum
|
|
}
|
|
if raw.PageSize > 0 {
|
|
pageSize = raw.PageSize
|
|
}
|
|
}
|
|
countText := "持续更新"
|
|
if playletCount > 0 {
|
|
countText = fmt.Sprintf("%d 部 持续更新", playletCount)
|
|
} else if total > 0 {
|
|
countText = fmt.Sprintf("%d 部 持续更新", total)
|
|
}
|
|
var seoSelections []playletser.SEOSelection
|
|
if q.SortType != 1 {
|
|
seoSelections = []playletser.SEOSelection{{Dimension: "排序", Value: playletser.TopicDetailSortLabel(q.SortType)}}
|
|
}
|
|
|
|
HTMLOK(c, "topicDetail.html", gin.H{
|
|
"title": title,
|
|
"navActive": "topic",
|
|
"seoInfo": seo,
|
|
"seoSelections": seoSelections,
|
|
"topic": raw,
|
|
"name": name,
|
|
"desc": desc,
|
|
"slug": q.Slug,
|
|
"topicId": q.ID,
|
|
"list": list,
|
|
"moreTopics": more,
|
|
"totalCount": total,
|
|
"playletCount": playletCount,
|
|
"countText": countText,
|
|
"pageNum": pageNum,
|
|
"pageSize": pageSize,
|
|
"sortType": q.SortType,
|
|
"sortLabel": playletser.TopicDetailSortLabel(q.SortType),
|
|
"seoEntityValid": q.ID > 0 && (name != "" || total > 0),
|
|
"heroCover": heroCover,
|
|
"covers": covers,
|
|
"pagination": playletser.BuildTopicDetailPagination(q, total),
|
|
"canonicalPath": q.URL(),
|
|
})
|
|
}
|