feat(user): 支持后台调整等级并限制极品专区可见性
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user