259 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			259 lines
		
	
	
		
			12 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package statistics
 | |
| 
 | |
| import (
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| // StatisticsMetricDTO 统计指标DTO
 | |
| type StatisticsMetricDTO struct {
 | |
| 	ID         string    `json:"id" comment:"统计指标唯一标识"`
 | |
| 	MetricType string    `json:"metric_type" comment:"指标类型"`
 | |
| 	MetricName string    `json:"metric_name" comment:"指标名称"`
 | |
| 	Dimension  string    `json:"dimension" comment:"统计维度"`
 | |
| 	Value      float64   `json:"value" comment:"指标值"`
 | |
| 	Metadata   string    `json:"metadata" comment:"额外维度信息"`
 | |
| 	Date       time.Time `json:"date" comment:"统计日期"`
 | |
| 	CreatedAt  time.Time `json:"created_at" comment:"创建时间"`
 | |
| 	UpdatedAt  time.Time `json:"updated_at" comment:"更新时间"`
 | |
| }
 | |
| 
 | |
| // StatisticsReportDTO 统计报告DTO
 | |
| type StatisticsReportDTO struct {
 | |
| 	ID           string     `json:"id" comment:"报告唯一标识"`
 | |
| 	ReportType   string     `json:"report_type" comment:"报告类型"`
 | |
| 	Title        string     `json:"title" comment:"报告标题"`
 | |
| 	Content      string     `json:"content" comment:"报告内容"`
 | |
| 	Period       string     `json:"period" comment:"统计周期"`
 | |
| 	UserRole     string     `json:"user_role" comment:"用户角色"`
 | |
| 	Status       string     `json:"status" comment:"报告状态"`
 | |
| 	GeneratedBy  string     `json:"generated_by" comment:"生成者ID"`
 | |
| 	GeneratedAt  *time.Time `json:"generated_at" comment:"生成时间"`
 | |
| 	ExpiresAt    *time.Time `json:"expires_at" comment:"过期时间"`
 | |
| 	CreatedAt    time.Time  `json:"created_at" comment:"创建时间"`
 | |
| 	UpdatedAt    time.Time  `json:"updated_at" comment:"更新时间"`
 | |
| }
 | |
| 
 | |
| // StatisticsDashboardDTO 统计仪表板DTO
 | |
| type StatisticsDashboardDTO struct {
 | |
| 	ID              string `json:"id" comment:"仪表板唯一标识"`
 | |
| 	Name            string `json:"name" comment:"仪表板名称"`
 | |
| 	Description     string `json:"description" comment:"仪表板描述"`
 | |
| 	UserRole        string `json:"user_role" comment:"用户角色"`
 | |
| 	IsDefault       bool   `json:"is_default" comment:"是否为默认仪表板"`
 | |
| 	IsActive        bool   `json:"is_active" comment:"是否激活"`
 | |
| 	Layout          string `json:"layout" comment:"布局配置"`
 | |
| 	Widgets         string `json:"widgets" comment:"组件配置"`
 | |
| 	Settings        string `json:"settings" comment:"设置配置"`
 | |
| 	RefreshInterval int    `json:"refresh_interval" comment:"刷新间隔(秒)"`
 | |
| 	CreatedBy       string `json:"created_by" comment:"创建者ID"`
 | |
| 	AccessLevel     string `json:"access_level" comment:"访问级别"`
 | |
| 	CreatedAt       time.Time `json:"created_at" comment:"创建时间"`
 | |
| 	UpdatedAt       time.Time `json:"updated_at" comment:"更新时间"`
 | |
| }
 | |
| 
 | |
| // DashboardDataDTO 仪表板数据DTO
 | |
| type DashboardDataDTO struct {
 | |
| 	// API调用统计
 | |
| 	APICalls struct {
 | |
| 		TotalCount   int64   `json:"total_count" comment:"总调用次数"`
 | |
| 		SuccessCount int64   `json:"success_count" comment:"成功调用次数"`
 | |
| 		FailedCount  int64   `json:"failed_count" comment:"失败调用次数"`
 | |
| 		SuccessRate  float64 `json:"success_rate" comment:"成功率"`
 | |
| 		AvgResponseTime float64 `json:"avg_response_time" comment:"平均响应时间"`
 | |
| 	} `json:"api_calls"`
 | |
| 
 | |
| 	// 用户统计
 | |
| 	Users struct {
 | |
| 		TotalCount     int64   `json:"total_count" comment:"总用户数"`
 | |
| 		CertifiedCount int64   `json:"certified_count" comment:"认证用户数"`
 | |
| 		ActiveCount    int64   `json:"active_count" comment:"活跃用户数"`
 | |
| 		CertificationRate float64 `json:"certification_rate" comment:"认证完成率"`
 | |
| 		RetentionRate  float64 `json:"retention_rate" comment:"留存率"`
 | |
| 	} `json:"users"`
 | |
| 
 | |
| 	// 财务统计
 | |
| 	Finance struct {
 | |
| 		TotalAmount   float64 `json:"total_amount" comment:"总金额"`
 | |
| 		RechargeAmount float64 `json:"recharge_amount" comment:"充值金额"`
 | |
| 		DeductAmount  float64 `json:"deduct_amount" comment:"扣款金额"`
 | |
| 		NetAmount     float64 `json:"net_amount" comment:"净金额"`
 | |
| 	} `json:"finance"`
 | |
| 
 | |
| 	// 产品统计
 | |
| 	Products struct {
 | |
| 		TotalProducts    int64   `json:"total_products" comment:"总产品数"`
 | |
| 		ActiveProducts   int64   `json:"active_products" comment:"活跃产品数"`
 | |
| 		TotalSubscriptions int64 `json:"total_subscriptions" comment:"总订阅数"`
 | |
| 		ActiveSubscriptions int64 `json:"active_subscriptions" comment:"活跃订阅数"`
 | |
| 	} `json:"products"`
 | |
| 
 | |
| 	// 认证统计
 | |
| 	Certification struct {
 | |
| 		TotalCertifications int64   `json:"total_certifications" comment:"总认证数"`
 | |
| 		CompletedCertifications int64 `json:"completed_certifications" comment:"完成认证数"`
 | |
| 		PendingCertifications int64 `json:"pending_certifications" comment:"待处理认证数"`
 | |
| 		FailedCertifications int64 `json:"failed_certifications" comment:"失败认证数"`
 | |
| 		CompletionRate      float64 `json:"completion_rate" comment:"完成率"`
 | |
| 	} `json:"certification"`
 | |
| 
 | |
| 	// 时间信息
 | |
| 	Period struct {
 | |
| 		StartDate string `json:"start_date" comment:"开始日期"`
 | |
| 		EndDate   string `json:"end_date" comment:"结束日期"`
 | |
| 		Period    string `json:"period" comment:"统计周期"`
 | |
| 	} `json:"period"`
 | |
| 
 | |
| 	// 元数据
 | |
| 	Metadata struct {
 | |
| 		GeneratedAt string `json:"generated_at" comment:"生成时间"`
 | |
| 		UserRole    string `json:"user_role" comment:"用户角色"`
 | |
| 		DataVersion string `json:"data_version" comment:"数据版本"`
 | |
| 	} `json:"metadata"`
 | |
| }
 | |
| 
 | |
| // RealtimeMetricsDTO 实时指标DTO
 | |
| type RealtimeMetricsDTO struct {
 | |
| 	MetricType string                 `json:"metric_type" comment:"指标类型"`
 | |
| 	Metrics    map[string]float64     `json:"metrics" comment:"指标数据"`
 | |
| 	Timestamp  time.Time              `json:"timestamp" comment:"时间戳"`
 | |
| 	Metadata   map[string]interface{} `json:"metadata" comment:"元数据"`
 | |
| }
 | |
| 
 | |
| // HistoricalMetricsDTO 历史指标DTO
 | |
| type HistoricalMetricsDTO struct {
 | |
| 	MetricType string                 `json:"metric_type" comment:"指标类型"`
 | |
| 	MetricName string                 `json:"metric_name" comment:"指标名称"`
 | |
| 	Dimension  string                 `json:"dimension" comment:"统计维度"`
 | |
| 	DataPoints []DataPointDTO         `json:"data_points" comment:"数据点"`
 | |
| 	Summary    MetricsSummaryDTO     `json:"summary" comment:"汇总信息"`
 | |
| 	Metadata   map[string]interface{} `json:"metadata" comment:"元数据"`
 | |
| }
 | |
| 
 | |
| // DataPointDTO 数据点DTO
 | |
| type DataPointDTO struct {
 | |
| 	Date  time.Time `json:"date" comment:"日期"`
 | |
| 	Value float64   `json:"value" comment:"值"`
 | |
| 	Label string    `json:"label" comment:"标签"`
 | |
| }
 | |
| 
 | |
| // MetricsSummaryDTO 指标汇总DTO
 | |
| type MetricsSummaryDTO struct {
 | |
| 	Total   float64 `json:"total" comment:"总值"`
 | |
| 	Average float64 `json:"average" comment:"平均值"`
 | |
| 	Max     float64 `json:"max" comment:"最大值"`
 | |
| 	Min     float64 `json:"min" comment:"最小值"`
 | |
| 	Count   int64   `json:"count" comment:"数据点数量"`
 | |
| 	GrowthRate float64 `json:"growth_rate" comment:"增长率"`
 | |
| 	Trend   string  `json:"trend" comment:"趋势"`
 | |
| }
 | |
| 
 | |
| // ReportContentDTO 报告内容DTO
 | |
| type ReportContentDTO struct {
 | |
| 	ReportType string                 `json:"report_type" comment:"报告类型"`
 | |
| 	Title      string                 `json:"title" comment:"报告标题"`
 | |
| 	Summary    map[string]interface{} `json:"summary" comment:"汇总信息"`
 | |
| 	Details    map[string]interface{} `json:"details" comment:"详细信息"`
 | |
| 	Charts     []ChartDTO             `json:"charts" comment:"图表数据"`
 | |
| 	Tables     []TableDTO             `json:"tables" comment:"表格数据"`
 | |
| 	Metadata   map[string]interface{} `json:"metadata" comment:"元数据"`
 | |
| }
 | |
| 
 | |
| // ChartDTO 图表DTO
 | |
| type ChartDTO struct {
 | |
| 	Type        string                 `json:"type" comment:"图表类型"`
 | |
| 	Title       string                 `json:"title" comment:"图表标题"`
 | |
| 	Data        map[string]interface{} `json:"data" comment:"图表数据"`
 | |
| 	Options     map[string]interface{} `json:"options" comment:"图表选项"`
 | |
| 	Description string                 `json:"description" comment:"图表描述"`
 | |
| }
 | |
| 
 | |
| // TableDTO 表格DTO
 | |
| type TableDTO struct {
 | |
| 	Title       string                   `json:"title" comment:"表格标题"`
 | |
| 	Headers     []string                 `json:"headers" comment:"表头"`
 | |
| 	Rows        [][]interface{}          `json:"rows" comment:"表格行数据"`
 | |
| 	Summary     map[string]interface{}   `json:"summary" comment:"汇总信息"`
 | |
| 	Description string                   `json:"description" comment:"表格描述"`
 | |
| }
 | |
| 
 | |
| // ExportDataDTO 导出数据DTO
 | |
| type ExportDataDTO struct {
 | |
| 	Format      string                   `json:"format" comment:"导出格式"`
 | |
| 	FileName    string                   `json:"file_name" comment:"文件名"`
 | |
| 	Data        []map[string]interface{} `json:"data" comment:"导出数据"`
 | |
| 	Headers     []string                 `json:"headers" comment:"表头"`
 | |
| 	Metadata    map[string]interface{}  `json:"metadata" comment:"元数据"`
 | |
| 	DownloadURL string                   `json:"download_url" comment:"下载链接"`
 | |
| }
 | |
| 
 | |
| // StatisticsQueryDTO 统计查询DTO
 | |
| type StatisticsQueryDTO struct {
 | |
| 	MetricType string    `json:"metric_type" form:"metric_type" comment:"指标类型"`
 | |
| 	MetricName string    `json:"metric_name" form:"metric_name" comment:"指标名称"`
 | |
| 	Dimension  string    `json:"dimension" form:"dimension" comment:"统计维度"`
 | |
| 	StartDate  time.Time `json:"start_date" form:"start_date" comment:"开始日期"`
 | |
| 	EndDate    time.Time `json:"end_date" form:"end_date" comment:"结束日期"`
 | |
| 	Period     string    `json:"period" form:"period" comment:"统计周期"`
 | |
| 	UserRole   string    `json:"user_role" form:"user_role" comment:"用户角色"`
 | |
| 	Limit      int       `json:"limit" form:"limit" comment:"限制数量"`
 | |
| 	Offset     int       `json:"offset" form:"offset" comment:"偏移量"`
 | |
| 	SortBy     string    `json:"sort_by" form:"sort_by" comment:"排序字段"`
 | |
| 	SortOrder  string    `json:"sort_order" form:"sort_order" comment:"排序顺序"`
 | |
| }
 | |
| 
 | |
| // ReportGenerationDTO 报告生成DTO
 | |
| type ReportGenerationDTO struct {
 | |
| 	ReportType string                 `json:"report_type" comment:"报告类型"`
 | |
| 	Title      string                 `json:"title" comment:"报告标题"`
 | |
| 	Period     string                 `json:"period" comment:"统计周期"`
 | |
| 	UserRole   string                 `json:"user_role" comment:"用户角色"`
 | |
| 	StartDate  time.Time             `json:"start_date" comment:"开始日期"`
 | |
| 	EndDate    time.Time             `json:"end_date" comment:"结束日期"`
 | |
| 	Filters    map[string]interface{} `json:"filters" comment:"过滤条件"`
 | |
| 	Format     string                 `json:"format" comment:"输出格式"`
 | |
| 	GeneratedBy string                `json:"generated_by" comment:"生成者ID"`
 | |
| }
 | |
| 
 | |
| // DashboardConfigDTO 仪表板配置DTO
 | |
| type DashboardConfigDTO struct {
 | |
| 	Name            string `json:"name" comment:"仪表板名称"`
 | |
| 	Description     string `json:"description" comment:"仪表板描述"`
 | |
| 	UserRole        string `json:"user_role" comment:"用户角色"`
 | |
| 	Layout          string `json:"layout" comment:"布局配置"`
 | |
| 	Widgets         string `json:"widgets" comment:"组件配置"`
 | |
| 	Settings        string `json:"settings" comment:"设置配置"`
 | |
| 	RefreshInterval int    `json:"refresh_interval" comment:"刷新间隔(秒)"`
 | |
| 	AccessLevel     string `json:"access_level" comment:"访问级别"`
 | |
| 	CreatedBy       string `json:"created_by" comment:"创建者ID"`
 | |
| }
 | |
| 
 | |
| // StatisticsResponseDTO 统计响应DTO
 | |
| type StatisticsResponseDTO struct {
 | |
| 	Success bool                   `json:"success" comment:"是否成功"`
 | |
| 	Message string                 `json:"message" comment:"响应消息"`
 | |
| 	Data    interface{}            `json:"data" comment:"响应数据"`
 | |
| 	Meta    map[string]interface{} `json:"meta" comment:"元数据"`
 | |
| 	Error   string                 `json:"error,omitempty" comment:"错误信息"`
 | |
| }
 | |
| 
 | |
| // PaginationDTO 分页DTO
 | |
| type PaginationDTO struct {
 | |
| 	Page     int   `json:"page" comment:"当前页"`
 | |
| 	PageSize int   `json:"page_size" comment:"每页大小"`
 | |
| 	Total    int64 `json:"total" comment:"总数量"`
 | |
| 	Pages    int   `json:"pages" comment:"总页数"`
 | |
| 	HasNext  bool  `json:"has_next" comment:"是否有下一页"`
 | |
| 	HasPrev  bool  `json:"has_prev" comment:"是否有上一页"`
 | |
| }
 | |
| 
 | |
| // StatisticsListResponseDTO 统计列表响应DTO
 | |
| type StatisticsListResponseDTO struct {
 | |
| 	Success    bool                   `json:"success" comment:"是否成功"`
 | |
| 	Message    string                 `json:"message" comment:"响应消息"`
 | |
| 	Data       []interface{}          `json:"data" comment:"数据列表"`
 | |
| 	Pagination PaginationDTO          `json:"pagination" comment:"分页信息"`
 | |
| 	Meta       map[string]interface{} `json:"meta" comment:"元数据"`
 | |
| 	Error      string                 `json:"error,omitempty" comment:"错误信息"`
 | |
| }
 | |
| 
 |