补齐论坛核心能力:讨论锁定、发帖本地草稿、标签精确筛选,以及私信与通知分流。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -198,6 +198,27 @@ func (h *Handlers) APIAdminLockPost(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": msg, "edit_locked": req.Locked})
|
||||
}
|
||||
|
||||
// APIAdminCommentsLockPost 锁定/解锁讨论(禁止新评论)
|
||||
func (h *Handlers) APIAdminCommentsLockPost(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
var req struct {
|
||||
Locked bool `json:"locked"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "参数错误"})
|
||||
return
|
||||
}
|
||||
if err := h.Post.SetCommentsLocked(uint(id), req.Locked); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
msg := "已开放讨论"
|
||||
if req.Locked {
|
||||
msg = "已锁定讨论"
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": msg, "comments_locked": req.Locked})
|
||||
}
|
||||
|
||||
// APIAdminPinPost 全局置顶/取消全局置顶(JSON)
|
||||
func (h *Handlers) APIAdminPinPost(c *gin.Context) {
|
||||
id, _ := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
@@ -911,6 +932,7 @@ func (h *Handlers) APIPosts(c *gin.Context) {
|
||||
boardID, _ := strconv.ParseUint(c.Query("board_id"), 10, 64)
|
||||
userID, _ := strconv.ParseUint(c.Query("user_id"), 10, 64)
|
||||
keyword := c.Query("keyword")
|
||||
tag := strings.TrimSpace(c.Query("tag"))
|
||||
|
||||
q := service.PostListQuery{
|
||||
BoardID: uint(boardID),
|
||||
@@ -918,6 +940,7 @@ func (h *Handlers) APIPosts(c *gin.Context) {
|
||||
Page: page,
|
||||
Size: size,
|
||||
Keyword: keyword,
|
||||
Tag: tag,
|
||||
Sort: c.DefaultQuery("sort", "latest"),
|
||||
ViewerID: h.currentUserID(c),
|
||||
ViewerIsAdmin: h.isAdmin(c),
|
||||
|
||||
@@ -94,14 +94,46 @@ func (h *Handlers) APIMarkConversationRead(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "已标为已读"})
|
||||
}
|
||||
|
||||
// APIMessageUnreadCount 未读私信数
|
||||
// APIMessageUnreadCount 未读私信数(含私信/通知分项)
|
||||
func (h *Handlers) APIMessageUnreadCount(c *gin.Context) {
|
||||
n, err := h.Message.UnreadCount(h.currentUserID(c))
|
||||
total, dm, notify, err := h.Message.UnreadCounts(h.currentUserID(c))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"count": n})
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"count": total,
|
||||
"dm_count": dm,
|
||||
"notify_count": notify,
|
||||
})
|
||||
}
|
||||
|
||||
// APIMessageNotifications 系统通知列表
|
||||
func (h *Handlers) APIMessageNotifications(c *gin.Context) {
|
||||
page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
|
||||
size, _ := strconv.Atoi(c.DefaultQuery("size", "30"))
|
||||
kind := c.Query("kind")
|
||||
uid := h.currentUserID(c)
|
||||
list, total, err := h.Message.ListNotifications(uid, page, size, kind)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"notifications": list,
|
||||
"total": total,
|
||||
"page": page,
|
||||
"kind": kind,
|
||||
})
|
||||
}
|
||||
|
||||
// APIMarkNotificationsRead 系统通知全部已读
|
||||
func (h *Handlers) APIMarkNotificationsRead(c *gin.Context) {
|
||||
if err := h.Message.MarkNotificationsRead(h.currentUserID(c)); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"message": "通知已全部标为已读"})
|
||||
}
|
||||
|
||||
// APISendMessage 发送私信
|
||||
|
||||
Reference in New Issue
Block a user