server: Go 服务器(REST+WSS 网关+JWT+Argon2+配对+素材直链+任务状态机);修复并发下线 send-on-closed-channel、下发查询 SQL 优先级、配对码原子占用、上传体积上限、JWT 默认密钥告警

This commit is contained in:
Qiufeng
2026-08-20 20:38:21 +08:00
parent bf25d8beac
commit cc8845dcec
44 changed files with 4995 additions and 0 deletions
@@ -0,0 +1,57 @@
package handlers
import (
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"everypublish/server/internal/api/response"
"everypublish/server/internal/models"
)
// NotificationHandler 站内通知处理器
type NotificationHandler struct {
DB *gorm.DB
}
// List 我的通知 + 未读数
func (h *NotificationHandler) List(c *gin.Context) {
q := h.DB.Model(&models.Notification{}).Where("workspace_id = ? and user_id = ?", c.GetUint64("wsid"), c.GetUint64("uid"))
if k := c.Query("kind"); k != "" {
q = q.Where("kind = ?", k)
}
var unread int64
q.Where("`read` = ?", false).Count(&unread)
var list []models.Notification
q.Order("id desc").Limit(100).Find(&list)
response.OK(c, gin.H{"list": list, "unread": unread})
}
// Read 标记已读
func (h *NotificationHandler) Read(c *gin.Context) {
id, err := strconv.ParseUint(c.Param("id"), 10, 64)
if err != nil {
response.Fail(c, http.StatusBadRequest, 1001, "参数不合法")
return
}
if err = h.DB.Model(&models.Notification{}).
Where("id = ? and user_id = ?", id, c.GetUint64("uid")).
Update("read", true).Error; err != nil {
response.Fail(c, http.StatusInternalServerError, 5000, "更新失败")
return
}
response.OK(c, nil)
}
// ReadAll 全部已读
func (h *NotificationHandler) ReadAll(c *gin.Context) {
if err := h.DB.Model(&models.Notification{}).
Where("workspace_id = ? and user_id = ?", c.GetUint64("wsid"), c.GetUint64("uid")).
Update("read", true).Error; err != nil {
response.Fail(c, http.StatusInternalServerError, 5000, "更新失败")
return
}
response.OK(c, nil)
}