Initial commit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"videoweb/app/service/playletser"
|
||||
"videoweb/pub/common/log"
|
||||
"videoweb/pub/common/useragent"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// UserCenter 个人中心:登录态刷新 getInfo 金币余额,并拉取收藏数量。
|
||||
func UserCenter(c *gin.Context) {
|
||||
data := gin.H{
|
||||
"title": "个人中心",
|
||||
"navActive": "userCenter",
|
||||
}
|
||||
setNoIndex(data, false)
|
||||
if attachWalletFromGetInfo(c, data) {
|
||||
RedirectToLogin(c)
|
||||
return
|
||||
}
|
||||
if useragent.TokenFromRequest(c.Request) != "" {
|
||||
raw, code, err := playletser.FetchCollectList(c, playletser.CollectListQuery{
|
||||
PageNum: 1,
|
||||
PageSize: 1,
|
||||
})
|
||||
if err != nil {
|
||||
aborted, retry := AbortSSRIfSessionExpired(c, code)
|
||||
if aborted {
|
||||
return
|
||||
}
|
||||
if retry {
|
||||
raw, _, err = playletser.FetchCollectList(c, playletser.CollectListQuery{
|
||||
PageNum: 1,
|
||||
PageSize: 1,
|
||||
})
|
||||
}
|
||||
if err != nil {
|
||||
log.Error("user-center collect count failed", log.E(err))
|
||||
raw = nil
|
||||
}
|
||||
}
|
||||
count := int64(0)
|
||||
if raw != nil {
|
||||
count = raw.TotalCount
|
||||
}
|
||||
if count < 0 {
|
||||
count = 0
|
||||
}
|
||||
data["collectCount"] = count
|
||||
data["collectCountText"] = strconv.FormatInt(count, 10) + "部"
|
||||
} else {
|
||||
data["collectCount"] = int64(0)
|
||||
data["collectCountText"] = "0部"
|
||||
}
|
||||
HTMLOK(c, "userCenter.html", data)
|
||||
}
|
||||
Reference in New Issue
Block a user