feat(user): 支持后台调整等级并限制极品专区可见性

This commit is contained in:
yml2213
2026-11-05 12:02:48 +08:00
parent 09f244a93d
commit 0d558bdce0
35 changed files with 934 additions and 131 deletions
@@ -4,6 +4,7 @@ import (
"net/http"
"strconv"
"hfb_sys/backend/internal/middleware"
filemodule "hfb_sys/backend/internal/modules/file"
"hfb_sys/backend/internal/sitecode"
"hfb_sys/backend/pkg/response"
@@ -12,7 +13,9 @@ import (
)
func (h *Handler) ListPublic(c *gin.Context) {
items, err := h.service.ListPublic(c.Request.Context(), parsePublicListQuery(c))
query := parsePublicListQuery(c)
query.ViewerUserID = optionalCurrentUserID(c)
items, err := h.service.ListPublic(c.Request.Context(), query)
if err != nil {
writeListingError(c, err)
return
@@ -26,7 +29,7 @@ func (h *Handler) FindPublic(c *gin.Context) {
return
}
siteCode := sitecode.FromRequest(c)
item, err := h.service.FindPublic(c.Request.Context(), id, siteCode)
item, err := h.service.FindPublic(c.Request.Context(), id, siteCode, optionalCurrentUserID(c))
if err != nil {
writeListingError(c, err)
return
@@ -34,6 +37,15 @@ func (h *Handler) FindPublic(c *gin.Context) {
response.OK(c, item)
}
func optionalCurrentUserID(c *gin.Context) uint64 {
value, ok := c.Get(middleware.ContextUserID)
if !ok {
return 0
}
userID, _ := value.(uint64)
return userID
}
func (h *Handler) Cover(c *gin.Context) {
id, ok := parseID(c)
if !ok {