补齐论坛核心能力:讨论锁定、发帖本地草稿、标签精确筛选,以及私信与通知分流。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-07 06:32:06 +08:00
parent 0f83183620
commit 10185178e2
28 changed files with 1165 additions and 266 deletions

View File

@@ -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 发送私信