| 
									
										
										
										
											2025-07-20 20:53:26 +08:00
										 |  |  | package routes | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-20 20:53:26 +08:00
										 |  |  | 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) | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  | 			products.GET("/available", r.handler.GetAvailableProducts) | 
					
						
							| 
									
										
										
										
											2025-07-20 20:53:26 +08:00
										 |  |  | 			products.GET("/:id", r.handler.GetProductDetail) | 
					
						
							|  |  |  | 			products.POST("", r.handler.CreateProduct) | 
					
						
							|  |  |  | 			products.PUT("/:id", r.handler.UpdateProduct) | 
					
						
							|  |  |  | 			products.DELETE("/:id", r.handler.DeleteProduct) | 
					
						
							| 
									
										
										
										
											2025-07-28 20:01:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  | 			// 组合包管理 | 
					
						
							|  |  |  | 			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) | 
					
						
							| 
									
										
										
										
											2025-07-28 20:01:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  | 			// 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) | 
					
						
							| 
									
										
										
										
											2025-07-31 15:41:00 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// 文档管理 | 
					
						
							|  |  |  | 			products.GET("/:id/documentation", r.handler.GetProductDocumentation) | 
					
						
							|  |  |  | 			products.POST("/:id/documentation", r.handler.CreateOrUpdateProductDocumentation) | 
					
						
							|  |  |  | 			products.DELETE("/:id/documentation", r.handler.DeleteProductDocumentation) | 
					
						
							| 
									
										
										
										
											2025-07-20 20:53:26 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-20 20:53:26 +08:00
										 |  |  | 		// 分类管理 | 
					
						
							|  |  |  | 		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) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-20 20:53:26 +08:00
										 |  |  | 		// 订阅管理 | 
					
						
							|  |  |  | 		subscriptions := adminGroup.Group("/subscriptions") | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			subscriptions.GET("", r.handler.ListSubscriptions) | 
					
						
							|  |  |  | 			subscriptions.GET("/stats", r.handler.GetSubscriptionStats) | 
					
						
							|  |  |  | 			subscriptions.PUT("/:id/price", r.handler.UpdateSubscriptionPrice) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2025-08-02 02:54:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// API调用记录管理 | 
					
						
							|  |  |  | 		apiCalls := adminGroup.Group("/api-calls") | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			apiCalls.GET("", r.handler.GetAdminApiCalls) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// 消费记录管理 | 
					
						
							|  |  |  | 		walletTransactions := adminGroup.Group("/wallet-transactions") | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			walletTransactions.GET("", r.handler.GetAdminWalletTransactions) | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// 充值记录管理 | 
					
						
							|  |  |  | 		rechargeRecords := adminGroup.Group("/recharge-records") | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			rechargeRecords.GET("", r.handler.GetAdminRechargeRecords) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2025-07-20 20:53:26 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2025-07-28 01:46:39 +08:00
										 |  |  | } |