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
+87
View File
@@ -0,0 +1,87 @@
package web
import (
"fmt"
"strings"
"videoweb/app/service/authser"
"videoweb/app/service/playletser"
"videoweb/pub/common/log"
"videoweb/pub/common/useragent"
"github.com/gin-gonic/gin"
)
type purchasedWork struct {
Title, Image, Info, Date, Progress, URL string
}
// PurchasedSeries 已购剧集:GET /api/app/playlet/bought/list。
// 文档:http://172.104.181.99:25319/swagger/index.html#/app短剧相关接口/get_api_app_playlet_bought_list
func PurchasedSeries(c *gin.Context) {
page, validPage := accountPageNum(c)
if !validPage {
NotFound(c)
return
}
data := gin.H{"title": "已购剧集 - 黄果短剧", "navActive": "purchased", "accountTab": "purchased"}
responses := gin.H{}
loadAccountSummary(c, data, responses)
size := 20
if useragent.TokenFromRequest(c.Request) == "" {
responses["playlet/bought/list"] = gin.H{"error": "暂无登录会话"}
data["purchasedResponse"] = responses["playlet/bought/list"]
HTMLOK(c, "purchased.html", data)
return
}
list, code, err := playletser.FetchBoughtList(c, page, size)
if retry, _ := authser.OnSessionExpired(c, code); retry {
list, _, err = playletser.FetchBoughtList(c, page, size)
}
if err == nil && list != nil {
responses["playlet/bought/list"] = gin.H{"code": 200, "data": list}
data["paging"] = makeAccountPage("/purchased", page, size, list.TotalCount)
works := make([]purchasedWork, 0, len(list.List))
for _, item := range list.List {
title := strings.TrimSpace(item.PlayName)
if title == "" {
title = strings.TrimSpace(item.Title)
}
if title == "" {
continue
}
info := fmt.Sprintf("已购 %d 集", item.BoughtChapterCount)
if item.TotalEpisode > 0 {
info += fmt.Sprintf(" / 共 %d 集", item.TotalEpisode)
}
info += fmt.Sprintf(" · %d 金币", item.CostCoins)
progress := 0
if item.TotalEpisode > 0 {
progress = item.WatchedCount * 100 / item.TotalEpisode
}
if progress < 0 {
progress = 0
}
if progress > 100 {
progress = 100
}
works = append(works, purchasedWork{
Title: title, Image: profileCover(item.Cover), Info: info,
Date: playletser.FormatHistoryAt(item.BoughtAt), Progress: fmt.Sprintf("%d%%", progress),
URL: playletser.ChapterPlayPath(item.Slug, item.ID, item.LastChapterID),
})
}
data["purchased"] = works
} else if err != nil {
responses["playlet/bought/list"] = gin.H{"error": "加载失败", "msg": err.Error()}
log.Error("fetch bought playlets failed", log.E(err))
data["purchasedUnavailable"] = true
} else {
responses["playlet/bought/list"] = gin.H{"code": code, "data": list}
}
data["purchasedResponse"] = responses["playlet/bought/list"]
HTMLOK(c, "purchased.html", data)
}