temp
This commit is contained in:
65
internal/infrastructure/http/routes/product_admin_routes.go
Normal file
65
internal/infrastructure/http/routes/product_admin_routes.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"tyapi-server/internal/infrastructure/http/handlers"
|
||||
sharedhttp "tyapi-server/internal/shared/http"
|
||||
"tyapi-server/internal/shared/middleware"
|
||||
)
|
||||
|
||||
// ProductAdminRoutes 产品管理员路由
|
||||
type ProductAdminRoutes struct {
|
||||
handler *handlers.ProductAdminHandler
|
||||
auth *middleware.JWTAuthMiddleware
|
||||
admin *middleware.AdminAuthMiddleware
|
||||
}
|
||||
|
||||
// NewProductAdminRoutes 创建产品管理员路由
|
||||
func NewProductAdminRoutes(
|
||||
handler *handlers.ProductAdminHandler,
|
||||
auth *middleware.JWTAuthMiddleware,
|
||||
admin *middleware.AdminAuthMiddleware,
|
||||
) *ProductAdminRoutes {
|
||||
return &ProductAdminRoutes{
|
||||
handler: handler,
|
||||
auth: auth,
|
||||
admin: admin,
|
||||
}
|
||||
}
|
||||
|
||||
// Register 注册路由
|
||||
func (r *ProductAdminRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
// 管理员路由组
|
||||
engine := router.GetEngine()
|
||||
adminGroup := engine.Group("/api/v1/admin")
|
||||
adminGroup.Use(r.auth.Handle()) // JWT认证
|
||||
adminGroup.Use(r.admin.Handle()) // 管理员权限验证
|
||||
{
|
||||
// 产品管理
|
||||
products := adminGroup.Group("/products")
|
||||
{
|
||||
products.GET("", r.handler.ListProducts)
|
||||
products.GET("/:id", r.handler.GetProductDetail)
|
||||
products.POST("", r.handler.CreateProduct)
|
||||
products.PUT("/:id", r.handler.UpdateProduct)
|
||||
products.DELETE("/:id", r.handler.DeleteProduct)
|
||||
}
|
||||
|
||||
// 分类管理
|
||||
categories := adminGroup.Group("/product-categories")
|
||||
{
|
||||
categories.GET("", r.handler.ListCategories)
|
||||
categories.GET("/:id", r.handler.GetCategoryDetail)
|
||||
categories.POST("", r.handler.CreateCategory)
|
||||
categories.PUT("/:id", r.handler.UpdateCategory)
|
||||
categories.DELETE("/:id", r.handler.DeleteCategory)
|
||||
}
|
||||
|
||||
// 订阅管理
|
||||
subscriptions := adminGroup.Group("/subscriptions")
|
||||
{
|
||||
subscriptions.GET("", r.handler.ListSubscriptions)
|
||||
subscriptions.GET("/stats", r.handler.GetSubscriptionStats)
|
||||
subscriptions.PUT("/:id/price", r.handler.UpdateSubscriptionPrice)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user