package routes import ( "github.com/gofiber/fiber/v2" "github.com/break/junhong_cmp_fiber/internal/handler/admin" "github.com/break/junhong_cmp_fiber/internal/model/dto" "github.com/break/junhong_cmp_fiber/pkg/openapi" ) // registerNotificationRoutes 注册当前后台账号的站内通知路由。 func registerNotificationRoutes(router fiber.Router, handler *admin.NotificationHandler, doc *openapi.Generator, basePath string) { notifications := router.Group("/notifications") groupPath := basePath + "/notifications" // 静态路径必须先于通知 ID 动态路径,避免被动态参数吞掉。 Register(notifications, doc, groupPath, "GET", "/unread-count", handler.UnreadCount, RouteSpec{ Summary: "查询通知未读数", Description: "仅查询当前认证后台账号的未过期未读通知,超过 99 条时 display_count 返回 99+。", Tags: []string{"站内通知"}, Output: new(dto.NotificationUnreadCountResponse), Auth: true, }) Register(notifications, doc, groupPath, "GET", "/unread-summary", handler.UnreadSummary, RouteSpec{ Summary: "查询通知未读分类汇总", Description: "返回当前认证后台账号未过期通知的总未读数及审批、临期、同步、系统四个固定类别计数。", Tags: []string{"站内通知"}, Output: new(dto.NotificationUnreadSummaryResponse), Auth: true, }) Register(notifications, doc, groupPath, "GET", "", handler.List, RouteSpec{ Summary: "查询通知列表", Description: "仅返回当前认证后台账号的未过期通知,固定按创建时间和通知 ID 倒序。", Tags: []string{"站内通知"}, Input: new(dto.NotificationListRequest), Output: new(dto.NotificationListResponse), Auth: true, }) Register(notifications, doc, groupPath, "PUT", "/read-all", handler.MarkAllRead, RouteSpec{ Summary: "批量标记通知已读", Description: "类别为空时更新当前认证后台账号全部未过期未读通知;指定有效类别时只更新该类别,重复调用幂等成功。", Tags: []string{"站内通知"}, Input: new(dto.NotificationReadAllRequest), Output: new(dto.NotificationReadAllResponse), Auth: true, }) Register(notifications, doc, groupPath, "GET", "/:id/target", handler.Target, RouteSpec{ Summary: "解析通知受控目标", Description: "先校验通知属于当前认证后台账号,再复核目标资源当前权限;只返回白名单结构化目标,不返回任意 URL。", Tags: []string{"站内通知"}, Input: new(dto.NotificationIDParams), Output: new(dto.NotificationTargetResponse), Auth: true, }) Register(notifications, doc, groupPath, "PUT", "/:id/read", handler.MarkRead, RouteSpec{ Summary: "标记单条通知已读", Description: "仅更新当前认证后台账号的通知;通知不存在、属于别人或已经已读均幂等成功。", Tags: []string{"站内通知"}, Input: new(dto.NotificationIDParams), Output: new(dto.NotificationReadResponse), Auth: true, }) }