temp
This commit is contained in:
81
internal/infrastructure/http/routes/product_routes.go
Normal file
81
internal/infrastructure/http/routes/product_routes.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"tyapi-server/internal/infrastructure/http/handlers"
|
||||
sharedhttp "tyapi-server/internal/shared/http"
|
||||
"tyapi-server/internal/shared/middleware"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// ProductRoutes 产品路由
|
||||
type ProductRoutes struct {
|
||||
productHandler *handlers.ProductHandler
|
||||
auth *middleware.JWTAuthMiddleware
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
// NewProductRoutes 创建产品路由
|
||||
func NewProductRoutes(
|
||||
productHandler *handlers.ProductHandler,
|
||||
auth *middleware.JWTAuthMiddleware,
|
||||
logger *zap.Logger,
|
||||
) *ProductRoutes {
|
||||
return &ProductRoutes{
|
||||
productHandler: productHandler,
|
||||
auth: auth,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
// Register 注册产品相关路由
|
||||
func (r *ProductRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
engine := router.GetEngine()
|
||||
|
||||
// 数据大厅 - 公开接口
|
||||
products := engine.Group("/api/v1/products")
|
||||
{
|
||||
// 获取产品列表(分页+筛选)
|
||||
products.GET("", r.productHandler.ListProducts)
|
||||
|
||||
// 获取产品详情
|
||||
products.GET("/:id", r.productHandler.GetProductDetail)
|
||||
|
||||
// 获取产品统计
|
||||
products.GET("/stats", r.productHandler.GetProductStats)
|
||||
|
||||
// 订阅产品(需要认证)
|
||||
products.POST("/:id/subscribe", r.auth.Handle(), r.productHandler.SubscribeProduct)
|
||||
}
|
||||
|
||||
// 分类 - 公开接口
|
||||
categories := engine.Group("/api/v1/categories")
|
||||
{
|
||||
// 获取分类列表
|
||||
categories.GET("", r.productHandler.ListCategories)
|
||||
|
||||
// 获取分类详情
|
||||
categories.GET("/:id", r.productHandler.GetCategoryDetail)
|
||||
}
|
||||
|
||||
// 我的订阅 - 需要认证
|
||||
my := engine.Group("/api/v1/my", r.auth.Handle())
|
||||
{
|
||||
subscriptions := my.Group("/subscriptions")
|
||||
{
|
||||
// 获取我的订阅列表
|
||||
subscriptions.GET("", r.productHandler.ListMySubscriptions)
|
||||
|
||||
// 获取我的订阅统计
|
||||
subscriptions.GET("/stats", r.productHandler.GetMySubscriptionStats)
|
||||
|
||||
// 获取订阅详情
|
||||
subscriptions.GET("/:id", r.productHandler.GetMySubscriptionDetail)
|
||||
|
||||
// 获取订阅使用情况
|
||||
subscriptions.GET("/:id/usage", r.productHandler.GetMySubscriptionUsage)
|
||||
}
|
||||
}
|
||||
|
||||
r.logger.Info("产品路由注册完成")
|
||||
}
|
||||
@@ -39,6 +39,7 @@ func (r *UserRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
usersGroup.POST("/register", r.handler.Register) // 用户注册
|
||||
usersGroup.POST("/login-password", r.handler.LoginWithPassword) // 密码登录
|
||||
usersGroup.POST("/login-sms", r.handler.LoginWithSMS) // 短信验证码登录
|
||||
usersGroup.POST("/reset-password", r.handler.ResetPassword) // 重置密码
|
||||
|
||||
// 需要认证的路由
|
||||
authenticated := usersGroup.Group("")
|
||||
|
||||
Reference in New Issue
Block a user