Initial commit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
谢宇宁
2026-09-29 11:47:47 +07:00
co-authored by Claude Opus 5.5
commit 0fbdba5ccf
622 changed files with 72105 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
package videoser
import (
"fmt"
"net/url"
"strconv"
"videoweb/app/service/playletser"
"videoweb/app/service/upstream"
"videoweb/pub/common/log"
"github.com/gin-gonic/gin"
)
const videoAllListPath = "/api/app/video/all/list"
// FetchVideoAllList 拉取 GET /api/app/video/all/list。
// 文档:http://172.104.181.99:25319/swagger/index.html#/视频相关接口/get_api_app_video_all_list
func FetchVideoAllList(c *gin.Context, q SeriesListQuery) (*VideoAllListResp, error) {
q.Normalize()
params := url.Values{}
params.Set("pageNum", strconv.Itoa(q.PageNum))
params.Set("pageSize", strconv.Itoa(q.PageSize))
params.Set("mediaType", strconv.Itoa(q.MediaType))
params.Set("sortType", strconv.Itoa(q.SortType))
if q.TopicID > 0 {
params.Set("topicId", strconv.FormatInt(q.TopicID, 10))
}
var env APIEnvelope[VideoAllListResp]
if err := upstream.GetPublicJSON(c, videoAllListPath+"?"+params.Encode(), &env); err != nil {
return nil, err
}
if env.Code != 200 {
return nil, fmt.Errorf("video all list code=%d msg=%s", env.Code, env.Msg)
}
return &env.Data, nil
}
// FetchVideoAllListOrEmpty 失败时返回空列表。
func FetchVideoAllListOrEmpty(c *gin.Context, q SeriesListQuery) *VideoAllListResp {
data, err := FetchVideoAllList(c, q)
if err != nil {
log.Error("fetch video all list failed", log.E(err))
return &VideoAllListResp{PageNum: q.PageNum, PageSize: q.PageSize}
}
if data == nil {
return &VideoAllListResp{PageNum: q.PageNum, PageSize: q.PageSize}
}
return data
}
// BuildSeriesListPagination 剧集列表分页。
func BuildSeriesListPagination(q SeriesListQuery, totalCount int64) playletser.PaginationVM {
q.Normalize()
return playletser.BuildPagination(func(p int) string {
nq := q
nq.PageNum = p
return nq.URL()
}, q.PageNum, q.PageSize, totalCount)
}