Files
谢宇宁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

45 lines
1.2 KiB
Go

package playletser
import (
"fmt"
"videoweb/app/service/upstream"
"github.com/gin-gonic/gin"
)
const hotLikePath = "/api/app/playlet/hot-like"
// PlayletHotSearchItem 对应 swagger proto.PlayletHotSearchItem。
type PlayletHotSearchItem struct {
Keyword string `json:"keyword"`
Count int64 `json:"count"`
}
// PlayletHotLikeResp 对应 swagger proto.PlayletHotLikeResp。
type PlayletHotLikeResp struct {
HotSearch []PlayletHotSearchItem `json:"hotSearch"`
GuessLike []CommonData `json:"guessLike"`
}
// FetchHotLike 获取前 10 个热搜词及按收藏量排序的 15 部猜你喜欢短剧。
// 文档:GET /api/app/playlet/hot-like → proto.PlayletHotLikeResp
func FetchHotLike(c *gin.Context) (*PlayletHotLikeResp, error) {
var env APIEnvelope[PlayletHotLikeResp]
if err := upstream.GetPublicJSON(c, hotLikePath, &env); err != nil {
return nil, err
}
if env.Code != 200 {
return nil, fmt.Errorf("playlet hot-like code=%d msg=%s tip=%s", env.Code, env.Msg, env.Tip)
}
return &env.Data, nil
}
// FetchHotLikeOrEmpty 失败时返回空热搜与猜你喜欢。
func FetchHotLikeOrEmpty(c *gin.Context) *PlayletHotLikeResp {
data, err := FetchHotLike(c)
if err != nil || data == nil {
return &PlayletHotLikeResp{}
}
return data
}