187 lines
7.8 KiB
Go
187 lines
7.8 KiB
Go
|
|
package statistics
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
// StatisticsApplicationService 统计应用服务接口
|
||
|
|
// 负责统计功能的业务逻辑编排和协调
|
||
|
|
type StatisticsApplicationService interface {
|
||
|
|
// ================ 指标管理 ================
|
||
|
|
|
||
|
|
// CreateMetric 创建统计指标
|
||
|
|
CreateMetric(ctx context.Context, cmd *CreateMetricCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// UpdateMetric 更新统计指标
|
||
|
|
UpdateMetric(ctx context.Context, cmd *UpdateMetricCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// DeleteMetric 删除统计指标
|
||
|
|
DeleteMetric(ctx context.Context, cmd *DeleteMetricCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// GetMetric 获取单个指标
|
||
|
|
GetMetric(ctx context.Context, query *GetMetricQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// GetMetrics 获取指标列表
|
||
|
|
GetMetrics(ctx context.Context, query *GetMetricsQuery) (*ListResponse, error)
|
||
|
|
|
||
|
|
// ================ 实时统计 ================
|
||
|
|
|
||
|
|
// GetRealtimeMetrics 获取实时指标
|
||
|
|
GetRealtimeMetrics(ctx context.Context, query *GetRealtimeMetricsQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// UpdateRealtimeMetric 更新实时指标
|
||
|
|
UpdateRealtimeMetric(ctx context.Context, metricType, metricName string, value float64) error
|
||
|
|
|
||
|
|
// ================ 历史统计 ================
|
||
|
|
|
||
|
|
// GetHistoricalMetrics 获取历史指标
|
||
|
|
GetHistoricalMetrics(ctx context.Context, query *GetHistoricalMetricsQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// AggregateMetrics 聚合指标
|
||
|
|
AggregateMetrics(ctx context.Context, metricType, dimension string, startDate, endDate time.Time) error
|
||
|
|
|
||
|
|
// ================ 仪表板管理 ================
|
||
|
|
|
||
|
|
// CreateDashboard 创建仪表板
|
||
|
|
CreateDashboard(ctx context.Context, cmd *CreateDashboardCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// UpdateDashboard 更新仪表板
|
||
|
|
UpdateDashboard(ctx context.Context, cmd *UpdateDashboardCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// DeleteDashboard 删除仪表板
|
||
|
|
DeleteDashboard(ctx context.Context, cmd *DeleteDashboardCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// GetDashboard 获取单个仪表板
|
||
|
|
GetDashboard(ctx context.Context, query *GetDashboardQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// GetDashboards 获取仪表板列表
|
||
|
|
GetDashboards(ctx context.Context, query *GetDashboardsQuery) (*ListResponse, error)
|
||
|
|
|
||
|
|
// SetDefaultDashboard 设置默认仪表板
|
||
|
|
SetDefaultDashboard(ctx context.Context, cmd *SetDefaultDashboardCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// ActivateDashboard 激活仪表板
|
||
|
|
ActivateDashboard(ctx context.Context, cmd *ActivateDashboardCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// DeactivateDashboard 停用仪表板
|
||
|
|
DeactivateDashboard(ctx context.Context, cmd *DeactivateDashboardCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// GetDashboardData 获取仪表板数据
|
||
|
|
GetDashboardData(ctx context.Context, query *GetDashboardDataQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// ================ 报告管理 ================
|
||
|
|
|
||
|
|
// GenerateReport 生成报告
|
||
|
|
GenerateReport(ctx context.Context, cmd *GenerateReportCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// GetReport 获取单个报告
|
||
|
|
GetReport(ctx context.Context, query *GetReportQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// GetReports 获取报告列表
|
||
|
|
GetReports(ctx context.Context, query *GetReportsQuery) (*ListResponse, error)
|
||
|
|
|
||
|
|
// DeleteReport 删除报告
|
||
|
|
DeleteReport(ctx context.Context, reportID string) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// ================ 统计分析 ================
|
||
|
|
|
||
|
|
// CalculateGrowthRate 计算增长率
|
||
|
|
CalculateGrowthRate(ctx context.Context, query *CalculateGrowthRateQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// CalculateTrend 计算趋势
|
||
|
|
CalculateTrend(ctx context.Context, query *CalculateTrendQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// CalculateCorrelation 计算相关性
|
||
|
|
CalculateCorrelation(ctx context.Context, query *CalculateCorrelationQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// CalculateMovingAverage 计算移动平均
|
||
|
|
CalculateMovingAverage(ctx context.Context, query *CalculateMovingAverageQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// CalculateSeasonality 计算季节性
|
||
|
|
CalculateSeasonality(ctx context.Context, query *CalculateSeasonalityQuery) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// ================ 数据导出 ================
|
||
|
|
|
||
|
|
// ExportData 导出数据
|
||
|
|
ExportData(ctx context.Context, cmd *ExportDataCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// ================ 定时任务 ================
|
||
|
|
|
||
|
|
// ProcessHourlyAggregation 处理小时级聚合
|
||
|
|
ProcessHourlyAggregation(ctx context.Context, date time.Time) error
|
||
|
|
|
||
|
|
// ProcessDailyAggregation 处理日级聚合
|
||
|
|
ProcessDailyAggregation(ctx context.Context, date time.Time) error
|
||
|
|
|
||
|
|
// ProcessWeeklyAggregation 处理周级聚合
|
||
|
|
ProcessWeeklyAggregation(ctx context.Context, date time.Time) error
|
||
|
|
|
||
|
|
// ProcessMonthlyAggregation 处理月级聚合
|
||
|
|
ProcessMonthlyAggregation(ctx context.Context, date time.Time) error
|
||
|
|
|
||
|
|
// CleanupExpiredData 清理过期数据
|
||
|
|
CleanupExpiredData(ctx context.Context) error
|
||
|
|
|
||
|
|
// ================ 管理员专用方法 ================
|
||
|
|
|
||
|
|
// AdminGetSystemStatistics 管理员获取系统统计
|
||
|
|
AdminGetSystemStatistics(ctx context.Context, period, startDate, endDate string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// AdminTriggerAggregation 管理员触发数据聚合
|
||
|
|
AdminTriggerAggregation(ctx context.Context, cmd *TriggerAggregationCommand) (*CommandResponse, error)
|
||
|
|
|
||
|
|
// AdminGetUserStatistics 管理员获取单个用户统计
|
||
|
|
AdminGetUserStatistics(ctx context.Context, userID string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// ================ 管理员独立域统计接口 ================
|
||
|
|
|
||
|
|
// AdminGetUserDomainStatistics 管理员获取用户域统计
|
||
|
|
AdminGetUserDomainStatistics(ctx context.Context, period, startDate, endDate string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// AdminGetApiDomainStatistics 管理员获取API域统计
|
||
|
|
AdminGetApiDomainStatistics(ctx context.Context, period, startDate, endDate string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// AdminGetConsumptionDomainStatistics 管理员获取消费域统计
|
||
|
|
AdminGetConsumptionDomainStatistics(ctx context.Context, period, startDate, endDate string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// AdminGetRechargeDomainStatistics 管理员获取充值域统计
|
||
|
|
AdminGetRechargeDomainStatistics(ctx context.Context, period, startDate, endDate string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// ================ 公开和用户统计方法 ================
|
||
|
|
|
||
|
|
// GetPublicStatistics 获取公开统计信息
|
||
|
|
GetPublicStatistics(ctx context.Context) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// GetUserStatistics 获取用户统计信息
|
||
|
|
GetUserStatistics(ctx context.Context, userID string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// ================ 独立统计接口 ================
|
||
|
|
|
||
|
|
// GetApiCallsStatistics 获取API调用统计
|
||
|
|
GetApiCallsStatistics(ctx context.Context, userID string, startDate, endDate time.Time, unit string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// GetConsumptionStatistics 获取消费统计
|
||
|
|
GetConsumptionStatistics(ctx context.Context, userID string, startDate, endDate time.Time, unit string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// GetRechargeStatistics 获取充值统计
|
||
|
|
GetRechargeStatistics(ctx context.Context, userID string, startDate, endDate time.Time, unit string) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// GetLatestProducts 获取最新产品推荐
|
||
|
|
GetLatestProducts(ctx context.Context, limit int) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// ================ 管理员排行榜接口 ================
|
||
|
|
|
||
|
|
// AdminGetUserCallRanking 获取用户调用排行榜
|
||
|
|
AdminGetUserCallRanking(ctx context.Context, rankingType, period string, limit int) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// AdminGetRechargeRanking 获取充值排行榜
|
||
|
|
AdminGetRechargeRanking(ctx context.Context, period string, limit int) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// AdminGetApiPopularityRanking 获取API受欢迎程度排行榜
|
||
|
|
AdminGetApiPopularityRanking(ctx context.Context, period string, limit int) (*QueryResponse, error)
|
||
|
|
|
||
|
|
// AdminGetTodayCertifiedEnterprises 获取今日认证企业列表
|
||
|
|
AdminGetTodayCertifiedEnterprises(ctx context.Context, limit int) (*QueryResponse, error)
|
||
|
|
}
|