feat: 帖子全局/板块置顶支持权重排序,优化列表与详情渲染
This commit is contained in:
@@ -244,11 +244,11 @@ func (h *Handlers) APIAdminCommentsLockPost(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": msg, "comments_locked": req.Locked})
|
||||
}
|
||||
|
||||
// APIAdminPinPost 全局置顶/取消全局置顶(JSON)
|
||||
// APIAdminPinPost 全局置顶/取消全局置顶(JSON),支持设置置顶顺序数值
|
||||
func (h *Handlers) APIAdminPinPost(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
var req struct {
|
||||
Pinned bool `json:"pinned"`
|
||||
Pinned int `json:"pinned"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数错误"})
|
||||
@@ -259,17 +259,17 @@ func (h *Handlers) APIAdminPinPost(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
msg := "已取消全局置顶"
|
||||
if req.Pinned {
|
||||
if req.Pinned > 0 {
|
||||
msg = "已全局置顶"
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": msg, "pinned": req.Pinned})
|
||||
}
|
||||
|
||||
// APIAdminBoardPinPost 板块内置顶/取消板块内置顶(JSON)
|
||||
// APIAdminBoardPinPost 板块内置顶/取消板块内置顶(JSON),支持设置置顶顺序数值
|
||||
func (h *Handlers) APIAdminBoardPinPost(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
var req struct {
|
||||
BoardPinned bool `json:"board_pinned"`
|
||||
BoardPinned int `json:"board_pinned"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数错误"})
|
||||
@@ -280,7 +280,7 @@ func (h *Handlers) APIAdminBoardPinPost(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
msg := "已取消板块置顶"
|
||||
if req.BoardPinned {
|
||||
if req.BoardPinned > 0 {
|
||||
msg = "已板块置顶"
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": msg, "board_pinned": req.BoardPinned})
|
||||
|
||||
Reference in New Issue
Block a user