暂存一下,防止丢失
This commit is contained in:
@@ -31,6 +31,9 @@ func RegisterAdminRoutes(router fiber.Router, handlers *bootstrap.Handlers, midd
|
||||
if handlers.ShopCommission != nil {
|
||||
registerShopCommissionRoutes(authGroup, handlers.ShopCommission, doc, basePath)
|
||||
}
|
||||
if handlers.Shop != nil {
|
||||
registerShopDetailRoute(authGroup, handlers.Shop, doc, basePath)
|
||||
}
|
||||
if handlers.CommissionWithdrawal != nil {
|
||||
registerCommissionWithdrawalRoutes(authGroup, handlers.CommissionWithdrawal, doc, basePath)
|
||||
}
|
||||
@@ -56,6 +59,9 @@ func RegisterAdminRoutes(router fiber.Router, handlers *bootstrap.Handlers, midd
|
||||
if handlers.ExportTask != nil {
|
||||
registerExportTaskRoutes(authGroup, handlers.ExportTask, doc, basePath)
|
||||
}
|
||||
if handlers.Notification != nil {
|
||||
registerNotificationRoutes(authGroup, handlers.Notification, doc, basePath)
|
||||
}
|
||||
if handlers.Device != nil {
|
||||
registerDeviceRoutes(authGroup, handlers.Device, handlers.DeviceImport, doc, basePath)
|
||||
}
|
||||
|
||||
68
internal/routes/notification.go
Normal file
68
internal/routes/notification.go
Normal file
@@ -0,0 +1,68 @@
|
||||
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,
|
||||
})
|
||||
}
|
||||
@@ -115,6 +115,9 @@ func RegisterPersonalCustomerRoutes(router fiber.Router, doc *openapi.Generator,
|
||||
// 需要认证的路由
|
||||
authGroup := router.Group("")
|
||||
authGroup.Use(personalAuthMiddleware.Authenticate())
|
||||
if handlers.ClientNotification != nil {
|
||||
registerPersonalNotificationRoutes(authGroup, handlers.ClientNotification, doc, basePath)
|
||||
}
|
||||
|
||||
// 获取个人资料
|
||||
Register(authGroup, doc, basePath, "GET", "/profile", handlers.PersonalCustomer.GetProfile, RouteSpec{
|
||||
|
||||
50
internal/routes/personal_notification.go
Normal file
50
internal/routes/personal_notification.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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 倒序。",
|
||||
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,
|
||||
})
|
||||
}
|
||||
@@ -55,6 +55,14 @@ func registerRoleRoutes(api fiber.Router, h *admin.RoleHandler, doc *openapi.Gen
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(roles, doc, groupPath, "PUT", "/:id/default-credit", h.UpdateDefaultCredit, RouteSpec{
|
||||
Summary: "更新客户角色的新建代理默认信用模板",
|
||||
Tags: []string{"角色"},
|
||||
Input: new(dto.UpdateRoleDefaultCreditParams),
|
||||
Output: new(dto.RoleDefaultCreditResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(roles, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
||||
Summary: "删除角色",
|
||||
Tags: []string{"角色"},
|
||||
|
||||
@@ -33,6 +33,15 @@ func registerShopRoutes(router fiber.Router, handler *admin.ShopHandler, doc *op
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(shops, doc, groupPath, "GET", "/business-owner-candidates", coreShopManagement(handler.BusinessOwnerCandidates), RouteSpec{
|
||||
Summary: "查询店铺业务员候选",
|
||||
Description: "仅超级管理员和平台账号可查询;只返回当前启用、未删除的平台账号最小摘要。",
|
||||
Tags: []string{"店铺管理"},
|
||||
Input: new(dto.ShopBusinessOwnerCandidateRequest),
|
||||
Output: new(dto.ShopBusinessOwnerCandidatePageResult),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(shops, doc, groupPath, "PUT", "/:id", coreShopManagement(handler.Update), RouteSpec{
|
||||
Summary: "更新店铺",
|
||||
Description: constants.ShopManagementAccessDescription,
|
||||
@@ -42,6 +51,15 @@ func registerShopRoutes(router fiber.Router, handler *admin.ShopHandler, doc *op
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(shops, doc, groupPath, "PUT", "/:id/credit-limit", handler.UpdateCreditLimit, RouteSpec{
|
||||
Summary: "调整既有店铺实际信用额度",
|
||||
Description: "后端不校验按钮权限;shop:credit-limit:manage 仅供前端控制按钮显示。",
|
||||
Tags: []string{"代理商资金管理"},
|
||||
Input: new(dto.UpdateShopCreditLimitParams),
|
||||
Output: new(dto.ShopCreditLimitResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(shops, doc, groupPath, "DELETE", "/:id", coreShopManagement(handler.Delete), RouteSpec{
|
||||
Summary: "删除店铺",
|
||||
Description: constants.ShopManagementAccessDescription,
|
||||
@@ -61,6 +79,19 @@ func registerShopRoutes(router fiber.Router, handler *admin.ShopHandler, doc *op
|
||||
})
|
||||
}
|
||||
|
||||
func registerShopDetailRoute(router fiber.Router, handler *admin.ShopHandler, doc *openapi.Generator, basePath string) {
|
||||
shops := router.Group("/shops")
|
||||
groupPath := basePath + "/shops"
|
||||
Register(shops, doc, groupPath, "GET", "/:id", coreShopManagement(handler.Detail), RouteSpec{
|
||||
Summary: "查询店铺详情",
|
||||
Description: constants.ShopManagementAccessDescription + " 返回与店铺列表一致的业务员归属摘要。",
|
||||
Tags: []string{"店铺管理"},
|
||||
Input: new(dto.IDReq),
|
||||
Output: new(dto.ShopResponse),
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
|
||||
func coreShopManagement(handler fiber.Handler) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
if middleware.GetUserTypeFromContext(c.UserContext()) == constants.UserTypeEnterprise {
|
||||
@@ -103,12 +134,13 @@ func registerShopCommissionRoutes(router fiber.Router, handler *admin.ShopCommis
|
||||
shops := router.Group("/shops")
|
||||
groupPath := basePath + "/shops"
|
||||
|
||||
Register(shops, doc, groupPath, "GET", "/fund-summary", handler.ListFundSummary, RouteSpec{
|
||||
Summary: "代理商资金概况",
|
||||
Tags: []string{"代理商资金管理"},
|
||||
Input: new(dto.ShopFundSummaryListReq),
|
||||
Output: new(dto.ShopFundSummaryPageResult),
|
||||
Auth: true,
|
||||
Register(shops, doc, groupPath, "GET", "/fund-summary", agentFundManagement(handler.ListFundSummary), RouteSpec{
|
||||
Summary: "代理商资金概况",
|
||||
Description: "按当前店铺数据范围分页返回主钱包、佣金及信用资金事实;现金可用、总可用和欠款均由服务端计算,读取不代表具有调额权限。",
|
||||
Tags: []string{"代理商资金管理"},
|
||||
Input: new(dto.ShopFundSummaryListReq),
|
||||
Output: new(dto.ShopFundSummaryPageResult),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(shops, doc, groupPath, "GET", "/:shop_id/withdrawal-requests", handler.ListWithdrawalRequests, RouteSpec{
|
||||
@@ -169,3 +201,12 @@ func registerShopCommissionRoutes(router fiber.Router, handler *admin.ShopCommis
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
|
||||
func agentFundManagement(handler fiber.Handler) fiber.Handler {
|
||||
return func(c *fiber.Ctx) error {
|
||||
if middleware.GetUserTypeFromContext(c.UserContext()) == constants.UserTypeEnterprise {
|
||||
return errors.New(errors.CodeForbidden, constants.AgentFundManagementForbiddenMessage)
|
||||
}
|
||||
return handler(c)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user