feat(notification): 新增全部标记已读接口
This commit is contained in:
@@ -77,6 +77,22 @@ func (h *NotificationHandler) Get(c *gin.Context) {
|
||||
response.ToResponse(out)
|
||||
}
|
||||
|
||||
// ReadAll 将当前用户全部通知标记为已读(前端进入通知页时调用)。
|
||||
func (h *NotificationHandler) ReadAll(c *gin.Context) {
|
||||
response := app.NewResponse(c)
|
||||
userID, ok := middleware.GetUserID(c.Request.Context())
|
||||
if !ok {
|
||||
response.ToErrorResponse(errcode.Unauthorized)
|
||||
return
|
||||
}
|
||||
out, e := h.svc.ReadAll(c.Request.Context(), userID)
|
||||
if e != nil {
|
||||
response.ToErrorResponse(e)
|
||||
return
|
||||
}
|
||||
response.ToResponse(out)
|
||||
}
|
||||
|
||||
// Read 标记通知已读(uuid 来自路径参数)。
|
||||
func (h *NotificationHandler) Read(c *gin.Context) {
|
||||
response := app.NewResponse(c)
|
||||
|
||||
@@ -121,6 +121,8 @@ func NewRouter() *gin.Engine {
|
||||
// 通知
|
||||
auth.GET("/notification", notificationHandler.List)
|
||||
auth.GET("/notification/unread", notificationHandler.Unread)
|
||||
// 静态路径 /notification/read-all 与 /notification/:uuid/read 段数不同,不会互相抢占
|
||||
auth.POST("/notification/read-all", notificationHandler.ReadAll)
|
||||
auth.GET("/notification/:uuid", notificationHandler.Get)
|
||||
auth.POST("/notification/:uuid/read", notificationHandler.Read)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user