syntax = "v1" import "common.api" // 管理后台仪表板接口 // 获取仪表板统计请求 type GetAdminDashboardStatsRequest { DateRange string `form:"date_range,optional,default=7d"` // 7d, 30d, 90d, 1y } // 获取仪表板统计响应 type GetAdminDashboardStatsResponse { BaseResponse Data AdminDashboardStatsData `json:"data"` } type AdminDashboardStatsData { // 总体统计 TotalUsers int64 `json:"total_users"` TotalPhotos int64 `json:"total_photos"` TotalCategories int64 `json:"total_categories"` TotalViews int64 `json:"total_views"` // 增长统计 UserGrowth AdminGrowthData `json:"user_growth"` PhotoGrowth AdminGrowthData `json:"photo_growth"` CategoryGrowth AdminGrowthData `json:"category_growth"` ViewGrowth AdminGrowthData `json:"view_growth"` // 存储统计 StorageStats AdminStorageStatsData `json:"storage_stats"` // 最新动态 RecentActivities []AdminActivityData `json:"recent_activities"` } type AdminGrowthData { Current int64 `json:"current"` // 当前数量 Previous int64 `json:"previous"` // 之前同期数量 Growth int64 `json:"growth"` // 增长数量 GrowthRate float64 `json:"growth_rate"` // 增长率 } type AdminStorageStatsData { TotalSize int64 `json:"total_size"` // 总存储大小 (字节) UsedSize int64 `json:"used_size"` // 已使用存储 AvailableSize int64 `json:"available_size"` // 可用存储 UsageRate float64 `json:"usage_rate"` // 使用率 PhotosSize int64 `json:"photos_size"` // 照片存储大小 ThumbnailsSize int64 `json:"thumbnails_size"` // 缩略图存储大小 AvatarsSize int64 `json:"avatars_size"` // 头像存储大小 } type AdminActivityData { Id int64 `json:"id"` Type string `json:"type"` // user_register, photo_upload, category_create, admin_login Description string `json:"description"` UserId int64 `json:"user_id,optional"` UserName string `json:"user_name,optional"` CreatedAt int64 `json:"created_at"` } // 获取分析数据请求 type GetAdminAnalyticsRequest { Type string `form:"type" validate:"required"` // users, photos, categories, views DateRange string `form:"date_range,optional,default=30d"` // 7d, 30d, 90d, 1y Granularity string `form:"granularity,optional,default=day"` // hour, day, week, month } // 获取分析数据响应 type GetAdminAnalyticsResponse { BaseResponse Data AdminAnalyticsData `json:"data"` } type AdminAnalyticsData { Type string `json:"type"` DateRange string `json:"date_range"` Granularity string `json:"granularity"` DataPoints []AdminAnalyticsDataPoint `json:"data_points"` Summary AdminAnalyticsSummary `json:"summary"` } type AdminAnalyticsDataPoint { Date string `json:"date"` // 日期 (YYYY-MM-DD 或 YYYY-MM-DD HH:mm) Value int64 `json:"value"` // 数值 Label string `json:"label,optional"` // 标签 } type AdminAnalyticsSummary { Total int64 `json:"total"` Average float64 `json:"average"` Peak int64 `json:"peak"` PeakDate string `json:"peak_date"` } // 获取热门内容请求 type GetAdminPopularContentRequest { Type string `form:"type" validate:"required"` // photos, categories, users Period string `form:"period,optional,default=7d"` // 7d, 30d, 90d Limit int `form:"limit,optional,default=10"` // 返回数量限制 } // 获取热门内容响应 type GetAdminPopularContentResponse { BaseResponse Data AdminPopularContentData `json:"data"` } type AdminPopularContentData { Type string `json:"type"` Period string `json:"period"` Items []AdminPopularContentItem `json:"items"` } type AdminPopularContentItem { Id int64 `json:"id"` Title string `json:"title"` Type string `json:"type"` ViewCount int64 `json:"view_count"` LikeCount int64 `json:"like_count,optional"` CommentCount int64 `json:"comment_count,optional"` Thumbnail string `json:"thumbnail,optional"` CreatedAt int64 `json:"created_at"` } // 获取操作日志请求 type GetAdminOperationLogsRequest { PageRequest UserId int64 `form:"user_id,optional"` Operation string `form:"operation,optional"` // login, create, update, delete Module string `form:"module,optional"` // user, photo, category, admin DateRange string `form:"date_range,optional"` // 日期范围 } // 获取操作日志响应 type GetAdminOperationLogsResponse { BaseResponse Data AdminOperationLogsData `json:"data"` } type AdminOperationLogsData { PageResponse Logs []AdminOperationLog `json:"logs"` } type AdminOperationLog { Id int64 `json:"id"` UserId int64 `json:"user_id"` UserName string `json:"user_name"` Operation string `json:"operation"` Module string `json:"module"` Target string `json:"target"` // 操作目标 Description string `json:"description"` IpAddress string `json:"ip_address"` UserAgent string `json:"user_agent"` Status string `json:"status"` // success, failed ErrorMsg string `json:"error_msg,optional"` CreatedAt int64 `json:"created_at"` } // 获取系统信息请求 type GetAdminSystemInfoRequest { } // 获取系统信息响应 type GetAdminSystemInfoResponse { BaseResponse Data AdminSystemInfoData `json:"data"` } type AdminSystemInfoData { Version string `json:"version"` BuildTime string `json:"build_time"` GoVersion string `json:"go_version"` Os string `json:"os"` Arch string `json:"arch"` Uptime int64 `json:"uptime"` // 运行时间 (秒) Memory AdminMemoryInfo `json:"memory"` Database AdminDatabaseInfo `json:"database"` Storage AdminStorageInfo `json:"storage"` } type AdminMemoryInfo { Allocated int64 `json:"allocated"` // 已分配内存 TotalAlloc int64 `json:"total_alloc"` // 总分配内存 System int64 `json:"system"` // 系统内存 NumGC int64 `json:"num_gc"` // GC 次数 } type AdminDatabaseInfo { Type string `json:"type"` // sqlite, postgresql Version string `json:"version"` Size int64 `json:"size"` // 数据库大小 Tables int `json:"tables"` // 表数量 Connections int `json:"connections"` // 连接数 } type AdminStorageInfo { Type string `json:"type"` // local, s3 TotalSpace int64 `json:"total_space"` // 总空间 UsedSpace int64 `json:"used_space"` // 已使用空间 FreeSpace int64 `json:"free_space"` // 剩余空间 } // 清理系统缓存请求 type ClearAdminSystemCacheRequest { CacheType string `json:"cache_type,optional"` // all, photos, users, categories } // 清理系统缓存响应 type ClearAdminSystemCacheResponse { BaseResponse Data ClearAdminSystemCacheData `json:"data"` } type ClearAdminSystemCacheData { ClearedItems int `json:"cleared_items"` CacheType string `json:"cache_type"` Message string `json:"message"` } // 管理后台仪表板接口组 - 需要管理员认证 @server( group: admin_dashboard prefix: /admin/dashboard jwt: AdminAuth ) service photography-api { @doc "获取仪表板统计" @handler getAdminDashboardStats get /stats (GetAdminDashboardStatsRequest) returns (GetAdminDashboardStatsResponse) @doc "获取分析数据" @handler getAdminAnalytics get /analytics (GetAdminAnalyticsRequest) returns (GetAdminAnalyticsResponse) @doc "获取热门内容" @handler getAdminPopularContent get /popular (GetAdminPopularContentRequest) returns (GetAdminPopularContentResponse) @doc "获取操作日志" @handler getAdminOperationLogs get /logs (GetAdminOperationLogsRequest) returns (GetAdminOperationLogsResponse) @doc "获取系统信息" @handler getAdminSystemInfo get /system (GetAdminSystemInfoRequest) returns (GetAdminSystemInfoResponse) @doc "清理系统缓存" @handler clearAdminSystemCache post /cache/clear (ClearAdminSystemCacheRequest) returns (ClearAdminSystemCacheResponse) }