99 lines
3.2 KiB
Go
99 lines
3.2 KiB
Go
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.admin.Handle()) // 管理员权限验证
|
|
{
|
|
// 产品管理
|
|
products := adminGroup.Group("/products")
|
|
{
|
|
products.GET("", r.handler.ListProducts)
|
|
products.GET("/available", r.handler.GetAvailableProducts)
|
|
products.GET("/:id", r.handler.GetProductDetail)
|
|
products.POST("", r.handler.CreateProduct)
|
|
products.PUT("/:id", r.handler.UpdateProduct)
|
|
products.DELETE("/:id", r.handler.DeleteProduct)
|
|
|
|
// 组合包管理
|
|
products.POST("/:id/package-items", r.handler.AddPackageItem)
|
|
products.PUT("/:id/package-items/:item_id", r.handler.UpdatePackageItem)
|
|
products.DELETE("/:id/package-items/:item_id", r.handler.RemovePackageItem)
|
|
products.PUT("/:id/package-items/reorder", r.handler.ReorderPackageItems)
|
|
products.PUT("/:id/package-items/batch", r.handler.UpdatePackageItems)
|
|
|
|
// API配置管理
|
|
products.GET("/:id/api-config", r.handler.GetProductApiConfig)
|
|
products.POST("/:id/api-config", r.handler.CreateProductApiConfig)
|
|
products.PUT("/:id/api-config", r.handler.UpdateProductApiConfig)
|
|
products.DELETE("/:id/api-config", r.handler.DeleteProductApiConfig)
|
|
|
|
// 文档管理
|
|
products.GET("/:id/documentation", r.handler.GetProductDocumentation)
|
|
products.POST("/:id/documentation", r.handler.CreateOrUpdateProductDocumentation)
|
|
products.DELETE("/:id/documentation", r.handler.DeleteProductDocumentation)
|
|
}
|
|
|
|
// 分类管理
|
|
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)
|
|
subscriptions.POST("/batch-update-prices", r.handler.BatchUpdateSubscriptionPrices)
|
|
}
|
|
|
|
|
|
|
|
// 消费记录管理
|
|
walletTransactions := adminGroup.Group("/wallet-transactions")
|
|
{
|
|
walletTransactions.GET("", r.handler.GetAdminWalletTransactions)
|
|
}
|
|
|
|
// 充值记录管理
|
|
rechargeRecords := adminGroup.Group("/recharge-records")
|
|
{
|
|
rechargeRecords.GET("", r.handler.GetAdminRechargeRecords)
|
|
}
|
|
}
|
|
}
|