new
This commit is contained in:
@@ -38,6 +38,7 @@ func (r *ApiRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
apiGroup := engine.Group("/api/v1")
|
||||
|
||||
{
|
||||
// API调用接口 - 不受频率限制(业务核心接口)
|
||||
apiGroup.POST("/:api_name", r.domainAuthMiddleware.Handle(""), r.apiHandler.HandleApiCall)
|
||||
|
||||
// Console专用接口 - 使用JWT认证,不需要域名认证
|
||||
@@ -62,6 +63,11 @@ func (r *ApiRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
|
||||
// API调用记录接口
|
||||
apiGroup.GET("/my/api-calls", r.authMiddleware.Handle(), r.apiHandler.GetUserApiCalls)
|
||||
|
||||
// 余额预警设置接口
|
||||
apiGroup.GET("/user/balance-alert/settings", r.authMiddleware.Handle(), r.apiHandler.GetUserBalanceAlertSettings)
|
||||
apiGroup.PUT("/user/balance-alert/settings", r.authMiddleware.Handle(), r.apiHandler.UpdateUserBalanceAlertSettings)
|
||||
apiGroup.POST("/user/balance-alert/test-sms", r.authMiddleware.Handle(), r.apiHandler.TestBalanceAlertSms)
|
||||
}
|
||||
|
||||
r.logger.Info("API路由注册完成")
|
||||
|
||||
@@ -54,6 +54,9 @@ func (r *CertificationRoutes) Register(router *http.GinRouter) {
|
||||
// 2. 提交企业信息(应用每日限流)
|
||||
authGroup.POST("/enterprise-info", r.dailyRateLimit.Handle(), r.handler.SubmitEnterpriseInfo)
|
||||
|
||||
// OCR营业执照识别接口
|
||||
authGroup.POST("/ocr/business-license", r.handler.RecognizeBusinessLicense)
|
||||
|
||||
// 3. 申请合同签署
|
||||
authGroup.POST("/apply-contract", r.handler.ApplyContract)
|
||||
|
||||
@@ -84,6 +87,7 @@ func (r *CertificationRoutes) GetRoutes() []RouteInfo {
|
||||
{Method: "GET", Path: "/api/v1/certifications", Handler: "ListCertifications", Auth: true},
|
||||
{Method: "GET", Path: "/api/v1/certifications/statistics", Handler: "GetCertificationStatistics", Auth: true},
|
||||
{Method: "POST", Path: "/api/v1/certifications/:id/enterprise-info", Handler: "SubmitEnterpriseInfo", Auth: true},
|
||||
{Method: "POST", Path: "/api/v1/certifications/ocr/business-license", Handler: "RecognizeBusinessLicense", Auth: true},
|
||||
{Method: "POST", Path: "/api/v1/certifications/apply-contract", Handler: "ApplyContract", Auth: true},
|
||||
{Method: "POST", Path: "/api/v1/certifications/retry", Handler: "RetryOperation", Auth: true},
|
||||
{Method: "POST", Path: "/api/v1/certifications/force-transition", Handler: "ForceTransitionStatus", Auth: true},
|
||||
|
||||
@@ -87,12 +87,21 @@ func (r *ProductAdminRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
walletTransactions := adminGroup.Group("/wallet-transactions")
|
||||
{
|
||||
walletTransactions.GET("", r.handler.GetAdminWalletTransactions)
|
||||
walletTransactions.GET("/export", r.handler.ExportAdminWalletTransactions)
|
||||
}
|
||||
|
||||
// API调用记录管理
|
||||
apiCalls := adminGroup.Group("/api-calls")
|
||||
{
|
||||
apiCalls.GET("", r.handler.GetAdminApiCalls)
|
||||
apiCalls.GET("/export", r.handler.ExportAdminApiCalls)
|
||||
}
|
||||
|
||||
// 充值记录管理
|
||||
rechargeRecords := adminGroup.Group("/recharge-records")
|
||||
{
|
||||
rechargeRecords.GET("", r.handler.GetAdminRechargeRecords)
|
||||
rechargeRecords.GET("/export", r.handler.ExportAdminRechargeRecords)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
165
internal/infrastructure/http/routes/statistics_routes.go
Normal file
165
internal/infrastructure/http/routes/statistics_routes.go
Normal file
@@ -0,0 +1,165 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"tyapi-server/internal/infrastructure/http/handlers"
|
||||
sharedhttp "tyapi-server/internal/shared/http"
|
||||
"tyapi-server/internal/shared/middleware"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// StatisticsRoutes 统计路由
|
||||
type StatisticsRoutes struct {
|
||||
statisticsHandler *handlers.StatisticsHandler
|
||||
auth *middleware.JWTAuthMiddleware
|
||||
optionalAuth *middleware.OptionalAuthMiddleware
|
||||
admin *middleware.AdminAuthMiddleware
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
// NewStatisticsRoutes 创建统计路由
|
||||
func NewStatisticsRoutes(
|
||||
statisticsHandler *handlers.StatisticsHandler,
|
||||
auth *middleware.JWTAuthMiddleware,
|
||||
optionalAuth *middleware.OptionalAuthMiddleware,
|
||||
admin *middleware.AdminAuthMiddleware,
|
||||
logger *zap.Logger,
|
||||
) *StatisticsRoutes {
|
||||
return &StatisticsRoutes{
|
||||
statisticsHandler: statisticsHandler,
|
||||
auth: auth,
|
||||
optionalAuth: optionalAuth,
|
||||
admin: admin,
|
||||
logger: logger,
|
||||
}
|
||||
}
|
||||
|
||||
// Register 注册统计相关路由
|
||||
func (r *StatisticsRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
engine := router.GetEngine()
|
||||
|
||||
// ================ 用户端统计路由 ================
|
||||
|
||||
// 统计公开接口
|
||||
statistics := engine.Group("/api/v1/statistics")
|
||||
{
|
||||
// 获取公开统计信息
|
||||
statistics.GET("/public", r.statisticsHandler.GetPublicStatistics)
|
||||
}
|
||||
|
||||
// 用户统计接口 - 需要认证
|
||||
userStats := engine.Group("/api/v1/statistics", r.auth.Handle())
|
||||
{
|
||||
// 获取用户统计信息
|
||||
userStats.GET("/user", r.statisticsHandler.GetUserStatistics)
|
||||
|
||||
// 独立统计接口(用户只能查询自己的数据)
|
||||
userStats.GET("/api-calls", r.statisticsHandler.GetApiCallsStatistics)
|
||||
userStats.GET("/consumption", r.statisticsHandler.GetConsumptionStatistics)
|
||||
userStats.GET("/recharge", r.statisticsHandler.GetRechargeStatistics)
|
||||
|
||||
// 获取最新产品推荐
|
||||
userStats.GET("/latest-products", r.statisticsHandler.GetLatestProducts)
|
||||
|
||||
// 获取指标列表
|
||||
userStats.GET("/metrics", r.statisticsHandler.GetMetrics)
|
||||
|
||||
// 获取指标详情
|
||||
userStats.GET("/metrics/:id", r.statisticsHandler.GetMetricDetail)
|
||||
|
||||
// 获取仪表板列表
|
||||
userStats.GET("/dashboards", r.statisticsHandler.GetDashboards)
|
||||
|
||||
// 获取仪表板详情
|
||||
userStats.GET("/dashboards/:id", r.statisticsHandler.GetDashboardDetail)
|
||||
|
||||
// 获取仪表板数据
|
||||
userStats.GET("/dashboards/:id/data", r.statisticsHandler.GetDashboardData)
|
||||
|
||||
// 获取报告列表
|
||||
userStats.GET("/reports", r.statisticsHandler.GetReports)
|
||||
|
||||
// 获取报告详情
|
||||
userStats.GET("/reports/:id", r.statisticsHandler.GetReportDetail)
|
||||
|
||||
// 创建报告
|
||||
userStats.POST("/reports", r.statisticsHandler.CreateReport)
|
||||
}
|
||||
|
||||
// ================ 管理员统计路由 ================
|
||||
|
||||
// 管理员路由组
|
||||
adminGroup := engine.Group("/api/v1/admin")
|
||||
adminGroup.Use(r.admin.Handle()) // 管理员权限验证
|
||||
{
|
||||
// 统计指标管理
|
||||
metrics := adminGroup.Group("/statistics/metrics")
|
||||
{
|
||||
metrics.GET("", r.statisticsHandler.AdminGetMetrics)
|
||||
metrics.POST("", r.statisticsHandler.AdminCreateMetric)
|
||||
metrics.PUT("/:id", r.statisticsHandler.AdminUpdateMetric)
|
||||
metrics.DELETE("/:id", r.statisticsHandler.AdminDeleteMetric)
|
||||
}
|
||||
|
||||
// 仪表板管理
|
||||
dashboards := adminGroup.Group("/statistics/dashboards")
|
||||
{
|
||||
dashboards.GET("", r.statisticsHandler.AdminGetDashboards)
|
||||
dashboards.POST("", r.statisticsHandler.AdminCreateDashboard)
|
||||
dashboards.PUT("/:id", r.statisticsHandler.AdminUpdateDashboard)
|
||||
dashboards.DELETE("/:id", r.statisticsHandler.AdminDeleteDashboard)
|
||||
}
|
||||
|
||||
// 报告管理
|
||||
reports := adminGroup.Group("/statistics/reports")
|
||||
{
|
||||
reports.GET("", r.statisticsHandler.AdminGetReports)
|
||||
}
|
||||
|
||||
// 系统统计
|
||||
system := adminGroup.Group("/statistics/system")
|
||||
{
|
||||
system.GET("", r.statisticsHandler.AdminGetSystemStatistics)
|
||||
}
|
||||
|
||||
// 独立域统计接口
|
||||
domainStats := adminGroup.Group("/statistics")
|
||||
{
|
||||
domainStats.GET("/user-domain", r.statisticsHandler.AdminGetUserDomainStatistics)
|
||||
domainStats.GET("/api-domain", r.statisticsHandler.AdminGetApiDomainStatistics)
|
||||
domainStats.GET("/consumption-domain", r.statisticsHandler.AdminGetConsumptionDomainStatistics)
|
||||
domainStats.GET("/recharge-domain", r.statisticsHandler.AdminGetRechargeDomainStatistics)
|
||||
}
|
||||
|
||||
// 排行榜接口
|
||||
rankings := adminGroup.Group("/statistics")
|
||||
{
|
||||
rankings.GET("/user-call-ranking", r.statisticsHandler.AdminGetUserCallRanking)
|
||||
rankings.GET("/recharge-ranking", r.statisticsHandler.AdminGetRechargeRanking)
|
||||
rankings.GET("/api-popularity-ranking", r.statisticsHandler.AdminGetApiPopularityRanking)
|
||||
rankings.GET("/today-certified-enterprises", r.statisticsHandler.AdminGetTodayCertifiedEnterprises)
|
||||
}
|
||||
|
||||
// 用户统计
|
||||
userStats := adminGroup.Group("/statistics/users")
|
||||
{
|
||||
userStats.GET("/:user_id", r.statisticsHandler.AdminGetUserStatistics)
|
||||
}
|
||||
|
||||
// 独立统计接口(管理员可查询任意用户)
|
||||
independentStats := adminGroup.Group("/statistics")
|
||||
{
|
||||
independentStats.GET("/api-calls", r.statisticsHandler.GetApiCallsStatistics)
|
||||
independentStats.GET("/consumption", r.statisticsHandler.GetConsumptionStatistics)
|
||||
independentStats.GET("/recharge", r.statisticsHandler.GetRechargeStatistics)
|
||||
}
|
||||
|
||||
// 数据聚合
|
||||
aggregation := adminGroup.Group("/statistics/aggregation")
|
||||
{
|
||||
aggregation.POST("/trigger", r.statisticsHandler.AdminTriggerAggregation)
|
||||
}
|
||||
}
|
||||
|
||||
r.logger.Info("统计路由注册完成")
|
||||
}
|
||||
Reference in New Issue
Block a user