feat: 完成API接口隔离设计和定义
Some checks failed
部署管理后台 / 🧪 测试和构建 (push) Failing after 1m5s
部署管理后台 / 🔒 安全扫描 (push) Has been skipped
部署前端网站 / 🧪 测试和构建 (push) Failing after 2m0s
部署管理后台 / 🚀 部署到生产环境 (push) Has been skipped
部署后端服务 / 🚀 构建并部署 (push) Has been skipped
部署后端服务 / 🧪 测试后端 (push) Failing after 3m15s
部署前端网站 / 🚀 部署到生产环境 (push) Has been skipped
部署管理后台 / 🔄 回滚部署 (push) Has been skipped
部署后端服务 / 🔄 回滚部署 (push) Has been skipped
Some checks failed
部署管理后台 / 🧪 测试和构建 (push) Failing after 1m5s
部署管理后台 / 🔒 安全扫描 (push) Has been skipped
部署前端网站 / 🧪 测试和构建 (push) Failing after 2m0s
部署管理后台 / 🚀 部署到生产环境 (push) Has been skipped
部署后端服务 / 🚀 构建并部署 (push) Has been skipped
部署后端服务 / 🧪 测试后端 (push) Failing after 3m15s
部署前端网站 / 🚀 部署到生产环境 (push) Has been skipped
部署管理后台 / 🔄 回滚部署 (push) Has been skipped
部署后端服务 / 🔄 回滚部署 (push) Has been skipped
🚀 主要功能: - 创建前端公共展示API (/api/v1/public/*) - 创建前端用户认证API (/api/v1/auth/*) - 创建管理后台完整API (/admin/*) - 实现双重认证体系设计 📋 新增文件: - api/desc/frontend/public.api - 前端公共接口定义 - api/desc/frontend/auth.api - 前端认证接口定义 - api/desc/admin.api - 管理后台主入口 - api/desc/admin/auth.api - 管理员认证接口 - api/desc/admin/users.api - 用户管理接口 - api/desc/admin/photos.api - 照片管理接口 - api/desc/admin/categories.api - 分类管理接口 - api/desc/admin/dashboard.api - 仪表板统计接口 🔧 更新文件: - api/desc/common.api - 扩展类型定义支持前端和管理后台 - api/desc/photography.api - 更新为前端主入口 - etc/photographyapi-api.yaml - 修复中间件配置 📚 文档: - docs/API_SEPARATION_DESIGN.md - 接口隔离设计方案 - docs/API_REFACTORING_TASKS.md - 详细任务规划 - docs/COMPLETED_TASKS_ARCHIVE.md - 已完成任务归档 ✨ 特性亮点: - 前端和管理后台权限完全隔离 - 优化的数据结构去除敏感信息 - 完整的CRUD和统计功能 - 支持批量操作和高级筛选 - 详细的仪表板分析功能
This commit is contained in:
254
backend/api/desc/admin/dashboard.api
Normal file
254
backend/api/desc/admin/dashboard.api
Normal file
@ -0,0 +1,254 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user