2026-04-25 11:59:10 +08:00
|
|
|
package routes
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"tyapi-server/internal/infrastructure/http/handlers"
|
|
|
|
|
sharedhttp "tyapi-server/internal/shared/http"
|
|
|
|
|
"tyapi-server/internal/shared/middleware"
|
|
|
|
|
|
|
|
|
|
"go.uber.org/zap"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// SubordinateRoutes 下属与邀请路由
|
|
|
|
|
type SubordinateRoutes struct {
|
|
|
|
|
handler *handlers.SubordinateHandler
|
|
|
|
|
auth *middleware.JWTAuthMiddleware
|
|
|
|
|
logger *zap.Logger
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewSubordinateRoutes 构造
|
|
|
|
|
func NewSubordinateRoutes(
|
|
|
|
|
handler *handlers.SubordinateHandler,
|
|
|
|
|
auth *middleware.JWTAuthMiddleware,
|
|
|
|
|
logger *zap.Logger,
|
|
|
|
|
) *SubordinateRoutes {
|
|
|
|
|
return &SubordinateRoutes{handler: handler, auth: auth, logger: logger}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Register 注册
|
|
|
|
|
func (r *SubordinateRoutes) Register(router *sharedhttp.GinRouter) {
|
|
|
|
|
g := router.GetEngine()
|
|
|
|
|
|
|
|
|
|
g.POST("/api/v1/sub-portal/register", r.handler.SubPortalRegister)
|
|
|
|
|
|
|
|
|
|
sub := g.Group("/api/v1/subordinate")
|
|
|
|
|
sub.Use(r.auth.Handle())
|
|
|
|
|
{
|
|
|
|
|
sub.POST("/invitations", r.handler.CreateInvitation)
|
|
|
|
|
sub.GET("/subordinates", r.handler.ListSubordinates)
|
|
|
|
|
sub.POST("/allocate", r.handler.Allocate)
|
|
|
|
|
sub.GET("/allocations", r.handler.ListAllocations)
|
|
|
|
|
sub.POST("/assign-subscription", r.handler.AssignSubscription)
|
|
|
|
|
sub.GET("/child-subscriptions", r.handler.ListChildSubscriptions)
|
|
|
|
|
sub.DELETE("/child-subscriptions/:subscription_id", r.handler.RemoveChildSubscription)
|
2026-04-25 19:17:19 +08:00
|
|
|
sub.POST("/purchase-quota", r.handler.PurchaseQuota)
|
|
|
|
|
sub.GET("/quota-purchases", r.handler.ListQuotaPurchases)
|
|
|
|
|
sub.GET("/child-quotas", r.handler.ListChildQuotaAccounts)
|
|
|
|
|
sub.GET("/my-quotas", r.handler.ListMyQuotaAccounts)
|
2026-04-25 11:59:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
r.logger.Info("下属账号路由注册完成")
|
|
|
|
|
}
|