增加站内信未读提醒和后台通知中心+txt 校验

This commit is contained in:
yml2213
2026-06-19 15:24:15 +08:00
parent 8d5094a8d0
commit a4cdc3e806
30 changed files with 1836 additions and 53 deletions
@@ -48,6 +48,34 @@ func (h *Handler) List(c *gin.Context) {
response.OK(c, result)
}
func (h *Handler) UnreadCount(c *gin.Context) {
userID, ok := currentUserID(c)
if !ok {
response.Unauthorized(c, "缺少用户上下文")
return
}
result, err := h.service.UnreadCount(c.Request.Context(), userID)
if err != nil {
writeNotificationError(c, err)
return
}
response.OK(c, result)
}
func (h *Handler) MarkAllRead(c *gin.Context) {
userID, ok := currentUserID(c)
if !ok {
response.Unauthorized(c, "缺少用户上下文")
return
}
count, err := h.service.MarkAllRead(c.Request.Context(), userID)
if err != nil {
writeNotificationError(c, err)
return
}
response.OK(c, gin.H{"read_count": count})
}
func (h *Handler) MarkRead(c *gin.Context) {
userID, ok := currentUserID(c)
if !ok {
@@ -79,6 +107,8 @@ func writeNotificationError(c *gin.Context, err error) {
switch {
case errors.Is(err, ErrDependencyUnavailable):
response.ServiceUnavailable(c, "数据库未连接")
case errors.Is(err, ErrNotificationNotFound):
response.NotFound(c, "通知不存在")
default:
response.ServiceUnavailable(c, "通知服务暂时不可用")
}