Files
junhong_cmp_fiber/internal/routes/personal_notification.go
break 73f5125d3d
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
七月迭代短暂完结,还有很多后端的关键东西没有弄,这是一版赶时间做的东西
2026-07-25 17:06:58 +08:00

51 lines
2.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package routes
import (
"github.com/gofiber/fiber/v2"
apphandler "github.com/break/junhong_cmp_fiber/internal/handler/app"
"github.com/break/junhong_cmp_fiber/internal/model/dto"
"github.com/break/junhong_cmp_fiber/pkg/openapi"
)
// registerPersonalNotificationRoutes 注册当前个人客户的简化站内通知路由。
func registerPersonalNotificationRoutes(router fiber.Router, handler *apphandler.ClientNotificationHandler, doc *openapi.Generator, basePath string) {
notifications := router.Group("/notifications")
groupPath := basePath + "/notifications"
Register(notifications, doc, groupPath, "GET", "/unread-count", handler.UnreadCount, RouteSpec{
Summary: "查询个人客户通知未读数",
Description: "仅查询当前认证个人客户的未过期业务通知,平台同步和系统运维通知不会进入结果。",
Tags: []string{"个人客户 - 站内通知"},
Output: new(dto.NotificationUnreadCountResponse),
Auth: true,
})
Register(notifications, doc, groupPath, "GET", "", handler.List, RouteSpec{
Summary: "查询个人客户通知列表",
Description: "仅返回当前认证个人客户的未过期业务通知,可按已读状态筛选,固定按创建时间和通知 ID 倒序。当前 C 端契约只承诺列表展示和未读弹窗ref_type/ref_id/ref_key 是资源引用与展示快照不是URL也不承诺可直接拼接页面路由。",
Tags: []string{"个人客户 - 站内通知"},
Input: new(dto.PersonalNotificationListRequest),
Output: new(dto.PersonalNotificationListResponse),
Auth: true,
})
// 静态路径必须先于通知 ID 动态路径,避免被动态参数吞掉。
Register(notifications, doc, groupPath, "PUT", "/read-all", handler.MarkAllRead, RouteSpec{
Summary: "全部标记个人客户通知已读",
Description: "只更新当前认证个人客户可见的未过期未读业务通知,重复调用幂等成功。",
Tags: []string{"个人客户 - 站内通知"},
Output: new(dto.NotificationReadAllResponse),
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,
})
}