Enhance ProductRoutes to include component report handling and related routes
This commit is contained in:
@@ -10,24 +10,27 @@ import (
|
||||
|
||||
// ProductRoutes 产品路由
|
||||
type ProductRoutes struct {
|
||||
productHandler *handlers.ProductHandler
|
||||
auth *middleware.JWTAuthMiddleware
|
||||
optionalAuth *middleware.OptionalAuthMiddleware
|
||||
logger *zap.Logger
|
||||
productHandler *handlers.ProductHandler
|
||||
componentReportHandler *handlers.ComponentReportHandler
|
||||
auth *middleware.JWTAuthMiddleware
|
||||
optionalAuth *middleware.OptionalAuthMiddleware
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
// NewProductRoutes 创建产品路由
|
||||
func NewProductRoutes(
|
||||
productHandler *handlers.ProductHandler,
|
||||
componentReportHandler *handlers.ComponentReportHandler,
|
||||
auth *middleware.JWTAuthMiddleware,
|
||||
optionalAuth *middleware.OptionalAuthMiddleware,
|
||||
logger *zap.Logger,
|
||||
) *ProductRoutes {
|
||||
return &ProductRoutes{
|
||||
productHandler: productHandler,
|
||||
auth: auth,
|
||||
optionalAuth: optionalAuth,
|
||||
logger: logger,
|
||||
productHandler: productHandler,
|
||||
componentReportHandler: componentReportHandler,
|
||||
auth: auth,
|
||||
optionalAuth: optionalAuth,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +58,19 @@ func (r *ProductRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
|
||||
// 订阅产品(需要认证)
|
||||
products.POST("/:id/subscribe", r.auth.Handle(), r.productHandler.SubscribeProduct)
|
||||
|
||||
// 组件报告相关路由(需要认证)
|
||||
componentReport := products.Group("/:id/component-report", r.auth.Handle())
|
||||
{
|
||||
// 获取报告下载信息
|
||||
componentReport.GET("/info", r.componentReportHandler.GetReportDownloadInfo)
|
||||
|
||||
// 创建支付订单(暂时注释,后续实现)
|
||||
// componentReport.POST("/create-order", r.componentReportHandler.CreateReportPaymentOrder)
|
||||
|
||||
// 下载报告文件
|
||||
componentReport.GET("/download/:downloadId", r.componentReportHandler.DownloadReport)
|
||||
}
|
||||
}
|
||||
|
||||
// 分类 - 公开接口
|
||||
@@ -87,6 +103,9 @@ func (r *ProductRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
// 取消订阅
|
||||
subscriptions.POST("/:id/cancel", r.productHandler.CancelMySubscription)
|
||||
}
|
||||
|
||||
// 我的组件报告下载历史
|
||||
my.GET("/component-reports", r.componentReportHandler.GetUserDownloadHistory)
|
||||
}
|
||||
|
||||
r.logger.Info("产品路由注册完成")
|
||||
|
||||
Reference in New Issue
Block a user