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:
116
backend/api/desc/admin/auth.api
Normal file
116
backend/api/desc/admin/auth.api
Normal file
@ -0,0 +1,116 @@
|
||||
syntax = "v1"
|
||||
|
||||
import "common.api"
|
||||
|
||||
// 管理员认证接口 - 强认证
|
||||
|
||||
// 管理员登录请求
|
||||
type AdminLoginRequest {
|
||||
Username string `json:"username" validate:"required"`
|
||||
Password string `json:"password" validate:"required"`
|
||||
Captcha string `json:"captcha,optional"` // 验证码 (可选)
|
||||
}
|
||||
|
||||
// 管理员登录响应
|
||||
type AdminLoginResponse {
|
||||
BaseResponse
|
||||
Data AdminLoginData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminLoginData {
|
||||
Token string `json:"token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
Admin Admin `json:"admin"`
|
||||
ExpiresIn int64 `json:"expires_in"` // Token 过期时间 (秒)
|
||||
}
|
||||
|
||||
// 管理员 Token 刷新请求
|
||||
type AdminRefreshTokenRequest {
|
||||
RefreshToken string `json:"refresh_token" validate:"required"`
|
||||
}
|
||||
|
||||
// 管理员 Token 刷新响应
|
||||
type AdminRefreshTokenResponse {
|
||||
BaseResponse
|
||||
Data AdminRefreshTokenData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminRefreshTokenData {
|
||||
Token string `json:"token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
ExpiresIn int64 `json:"expires_in"`
|
||||
}
|
||||
|
||||
// 管理员信息响应
|
||||
type AdminProfileResponse {
|
||||
BaseResponse
|
||||
Data Admin `json:"data"`
|
||||
}
|
||||
|
||||
// 管理员更新信息请求
|
||||
type UpdateAdminProfileRequest {
|
||||
Username string `json:"username,optional"`
|
||||
Email string `json:"email,optional"`
|
||||
Avatar string `json:"avatar,optional"`
|
||||
}
|
||||
|
||||
// 管理员更新信息响应
|
||||
type UpdateAdminProfileResponse {
|
||||
BaseResponse
|
||||
Data Admin `json:"data"`
|
||||
}
|
||||
|
||||
// 管理员修改密码请求
|
||||
type ChangeAdminPasswordRequest {
|
||||
OldPassword string `json:"old_password" validate:"required"`
|
||||
NewPassword string `json:"new_password" validate:"required,min=8"`
|
||||
}
|
||||
|
||||
// 管理员修改密码响应
|
||||
type ChangeAdminPasswordResponse {
|
||||
BaseResponse
|
||||
}
|
||||
|
||||
// 管理员登出响应
|
||||
type AdminLogoutResponse {
|
||||
BaseResponse
|
||||
}
|
||||
|
||||
// 管理员认证接口组 - 无需认证
|
||||
@server(
|
||||
group: admin_auth
|
||||
prefix: /admin/auth
|
||||
)
|
||||
service photography-api {
|
||||
@doc "管理员登录"
|
||||
@handler adminLogin
|
||||
post /login (AdminLoginRequest) returns (AdminLoginResponse)
|
||||
|
||||
@doc "刷新管理员Token"
|
||||
@handler adminRefreshToken
|
||||
post /refresh (AdminRefreshTokenRequest) returns (AdminRefreshTokenResponse)
|
||||
}
|
||||
|
||||
// 管理员认证接口组 - 需要认证
|
||||
@server(
|
||||
group: admin_auth
|
||||
prefix: /admin/auth
|
||||
jwt: AdminAuth
|
||||
)
|
||||
service photography-api {
|
||||
@doc "获取管理员信息"
|
||||
@handler getAdminProfile
|
||||
get /profile returns (AdminProfileResponse)
|
||||
|
||||
@doc "更新管理员信息"
|
||||
@handler updateAdminProfile
|
||||
put /profile (UpdateAdminProfileRequest) returns (UpdateAdminProfileResponse)
|
||||
|
||||
@doc "修改管理员密码"
|
||||
@handler changeAdminPassword
|
||||
post /change-password (ChangeAdminPasswordRequest) returns (ChangeAdminPasswordResponse)
|
||||
|
||||
@doc "管理员登出"
|
||||
@handler adminLogout
|
||||
post /logout returns (AdminLogoutResponse)
|
||||
}
|
||||
236
backend/api/desc/admin/categories.api
Normal file
236
backend/api/desc/admin/categories.api
Normal file
@ -0,0 +1,236 @@
|
||||
syntax = "v1"
|
||||
|
||||
import "common.api"
|
||||
|
||||
// 管理后台分类管理接口
|
||||
|
||||
// 获取分类列表请求
|
||||
type GetAdminCategoryListRequest {
|
||||
PageRequest
|
||||
Keyword string `form:"keyword,optional"`
|
||||
Status string `form:"status,optional"` // active, inactive
|
||||
SortBy string `form:"sort_by,optional,default=sort_order_asc"` // 排序方式
|
||||
WithStats bool `form:"with_stats,optional"` // 是否包含统计信息
|
||||
}
|
||||
|
||||
// 获取分类列表响应
|
||||
type GetAdminCategoryListResponse {
|
||||
BaseResponse
|
||||
Data AdminCategoryListData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminCategoryListData {
|
||||
PageResponse
|
||||
Categories []AdminCategory `json:"categories"`
|
||||
}
|
||||
|
||||
// 获取分类详情请求
|
||||
type GetAdminCategoryRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 获取分类详情响应
|
||||
type GetAdminCategoryResponse {
|
||||
BaseResponse
|
||||
Data AdminCategoryDetail `json:"data"`
|
||||
}
|
||||
|
||||
// 创建分类请求
|
||||
type CreateAdminCategoryRequest {
|
||||
Name string `json:"name" validate:"required"`
|
||||
Description string `json:"description,optional"`
|
||||
SortOrder int `json:"sort_order,optional,default=0"` // 排序权重
|
||||
Status string `json:"status,optional,default=active"` // active, inactive
|
||||
CoverImage string `json:"cover_image,optional"` // 分类封面图
|
||||
}
|
||||
|
||||
// 创建分类响应
|
||||
type CreateAdminCategoryResponse {
|
||||
BaseResponse
|
||||
Data AdminCategory `json:"data"`
|
||||
}
|
||||
|
||||
// 更新分类请求
|
||||
type UpdateAdminCategoryRequest {
|
||||
Id int64 `path:"id"`
|
||||
Name string `json:"name,optional"`
|
||||
Description string `json:"description,optional"`
|
||||
SortOrder int `json:"sort_order,optional"`
|
||||
Status string `json:"status,optional"`
|
||||
CoverImage string `json:"cover_image,optional"`
|
||||
}
|
||||
|
||||
// 更新分类响应
|
||||
type UpdateAdminCategoryResponse {
|
||||
BaseResponse
|
||||
Data AdminCategory `json:"data"`
|
||||
}
|
||||
|
||||
// 删除分类请求
|
||||
type DeleteAdminCategoryRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 删除分类响应
|
||||
type DeleteAdminCategoryResponse {
|
||||
BaseResponse
|
||||
}
|
||||
|
||||
// 分类排序请求
|
||||
type SortAdminCategoriesRequest {
|
||||
Categories []AdminCategorySortItem `json:"categories" validate:"required"`
|
||||
}
|
||||
|
||||
type AdminCategorySortItem {
|
||||
Id int64 `json:"id" validate:"required"`
|
||||
SortOrder int `json:"sort_order" validate:"required"`
|
||||
}
|
||||
|
||||
// 分类排序响应
|
||||
type SortAdminCategoriesResponse {
|
||||
BaseResponse
|
||||
}
|
||||
|
||||
// 更新分类状态请求
|
||||
type UpdateAdminCategoryStatusRequest {
|
||||
Id int64 `path:"id"`
|
||||
Status string `json:"status" validate:"required"` // active, inactive
|
||||
}
|
||||
|
||||
// 更新分类状态响应
|
||||
type UpdateAdminCategoryStatusResponse {
|
||||
BaseResponse
|
||||
Data AdminCategory `json:"data"`
|
||||
}
|
||||
|
||||
// 批量操作分类请求
|
||||
type BatchAdminCategoryOperationRequest {
|
||||
CategoryIds []int64 `json:"category_ids" validate:"required"`
|
||||
Operation string `json:"operation" validate:"required"` // activate, deactivate, delete
|
||||
}
|
||||
|
||||
// 批量操作分类响应
|
||||
type BatchAdminCategoryOperationResponse {
|
||||
BaseResponse
|
||||
Data BatchAdminCategoryOperationData `json:"data"`
|
||||
}
|
||||
|
||||
type BatchAdminCategoryOperationData {
|
||||
SuccessCount int `json:"success_count"`
|
||||
FailedCount int `json:"failed_count"`
|
||||
FailedIds []int64 `json:"failed_ids"`
|
||||
}
|
||||
|
||||
// 分类统计请求
|
||||
type GetAdminCategoryStatsRequest {
|
||||
DateRange string `form:"date_range,optional,default=7d"` // 7d, 30d, 90d
|
||||
}
|
||||
|
||||
// 分类统计响应
|
||||
type GetAdminCategoryStatsResponse {
|
||||
BaseResponse
|
||||
Data AdminCategoryStatsData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminCategoryStatsData {
|
||||
TotalCategories int64 `json:"total_categories"`
|
||||
ActiveCategories int64 `json:"active_categories"`
|
||||
EmptyCategories int64 `json:"empty_categories"` // 没有照片的分类
|
||||
NewCategories int64 `json:"new_categories"` // 指定时间范围内新增分类
|
||||
PopularCategories []AdminCategoryPopularItem `json:"popular_categories"` // 热门分类
|
||||
}
|
||||
|
||||
type AdminCategoryPopularItem {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
PhotoCount int64 `json:"photo_count"`
|
||||
ViewCount int64 `json:"view_count"`
|
||||
}
|
||||
|
||||
// 分类照片统计请求
|
||||
type GetAdminCategoryPhotoStatsRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 分类照片统计响应
|
||||
type GetAdminCategoryPhotoStatsResponse {
|
||||
BaseResponse
|
||||
Data AdminCategoryPhotoStatsData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminCategoryPhotoStatsData {
|
||||
CategoryId int64 `json:"category_id"`
|
||||
TotalPhotos int64 `json:"total_photos"`
|
||||
PublishedPhotos int64 `json:"published_photos"`
|
||||
DraftPhotos int64 `json:"draft_photos"`
|
||||
FeaturedPhotos int64 `json:"featured_photos"`
|
||||
TotalViews int64 `json:"total_views"`
|
||||
RecentPhotos []AdminPhoto `json:"recent_photos"` // 最近上传的照片
|
||||
}
|
||||
|
||||
// 上传分类封面图请求
|
||||
type UploadAdminCategoryCoverRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 上传分类封面图响应
|
||||
type UploadAdminCategoryCoverResponse {
|
||||
BaseResponse
|
||||
Data UploadAdminCategoryCoverData `json:"data"`
|
||||
}
|
||||
|
||||
type UploadAdminCategoryCoverData {
|
||||
CoverImageUrl string `json:"cover_image_url"`
|
||||
}
|
||||
|
||||
// 管理后台分类管理接口组 - 需要管理员认证
|
||||
@server(
|
||||
group: admin_categories
|
||||
prefix: /admin/categories
|
||||
jwt: AdminAuth
|
||||
)
|
||||
service photography-api {
|
||||
@doc "获取分类列表"
|
||||
@handler getAdminCategoryList
|
||||
get / (GetAdminCategoryListRequest) returns (GetAdminCategoryListResponse)
|
||||
|
||||
@doc "创建分类"
|
||||
@handler createAdminCategory
|
||||
post / (CreateAdminCategoryRequest) returns (CreateAdminCategoryResponse)
|
||||
|
||||
@doc "获取分类详情"
|
||||
@handler getAdminCategory
|
||||
get /:id (GetAdminCategoryRequest) returns (GetAdminCategoryResponse)
|
||||
|
||||
@doc "更新分类"
|
||||
@handler updateAdminCategory
|
||||
put /:id (UpdateAdminCategoryRequest) returns (UpdateAdminCategoryResponse)
|
||||
|
||||
@doc "删除分类"
|
||||
@handler deleteAdminCategory
|
||||
delete /:id (DeleteAdminCategoryRequest) returns (DeleteAdminCategoryResponse)
|
||||
|
||||
@doc "更新分类状态"
|
||||
@handler updateAdminCategoryStatus
|
||||
put /:id/status (UpdateAdminCategoryStatusRequest) returns (UpdateAdminCategoryStatusResponse)
|
||||
|
||||
@doc "上传分类封面图"
|
||||
@handler uploadAdminCategoryCover
|
||||
post /:id/cover (UploadAdminCategoryCoverRequest) returns (UploadAdminCategoryCoverResponse)
|
||||
|
||||
@doc "获取分类照片统计"
|
||||
@handler getAdminCategoryPhotoStats
|
||||
get /:id/photo-stats (GetAdminCategoryPhotoStatsRequest) returns (GetAdminCategoryPhotoStatsResponse)
|
||||
|
||||
@doc "分类排序"
|
||||
@handler sortAdminCategories
|
||||
post /sort (SortAdminCategoriesRequest) returns (SortAdminCategoriesResponse)
|
||||
|
||||
@doc "批量操作分类"
|
||||
@handler batchAdminCategoryOperation
|
||||
post /batch (BatchAdminCategoryOperationRequest) returns (BatchAdminCategoryOperationResponse)
|
||||
|
||||
@doc "获取分类统计"
|
||||
@handler getAdminCategoryStats
|
||||
get /stats (GetAdminCategoryStatsRequest) returns (GetAdminCategoryStatsResponse)
|
||||
}
|
||||
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)
|
||||
}
|
||||
216
backend/api/desc/admin/photos.api
Normal file
216
backend/api/desc/admin/photos.api
Normal file
@ -0,0 +1,216 @@
|
||||
syntax = "v1"
|
||||
|
||||
import "common.api"
|
||||
|
||||
// 管理后台照片管理接口
|
||||
|
||||
// 获取照片列表请求
|
||||
type GetAdminPhotoListRequest {
|
||||
PageRequest
|
||||
CategoryId int64 `form:"category_id,optional"`
|
||||
UserId int64 `form:"user_id,optional"`
|
||||
Keyword string `form:"keyword,optional"`
|
||||
Status string `form:"status,optional"` // published, draft, deleted
|
||||
Featured string `form:"featured,optional"` // true, false
|
||||
SortBy string `form:"sort_by,optional,default=created_at_desc"` // 排序方式
|
||||
DateRange string `form:"date_range,optional"` // 日期范围筛选
|
||||
}
|
||||
|
||||
// 获取照片列表响应
|
||||
type GetAdminPhotoListResponse {
|
||||
BaseResponse
|
||||
Data AdminPhotoListData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminPhotoListData {
|
||||
PageResponse
|
||||
Photos []AdminPhoto `json:"photos"`
|
||||
}
|
||||
|
||||
// 获取照片详情请求
|
||||
type GetAdminPhotoRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 获取照片详情响应
|
||||
type GetAdminPhotoResponse {
|
||||
BaseResponse
|
||||
Data AdminPhotoDetail `json:"data"`
|
||||
}
|
||||
|
||||
// 上传照片请求
|
||||
type UploadAdminPhotoRequest {
|
||||
Title string `json:"title" validate:"required"`
|
||||
Description string `json:"description,optional"`
|
||||
CategoryId int64 `json:"category_id" validate:"required"`
|
||||
Tags string `json:"tags,optional"` // 标签 (逗号分隔)
|
||||
Featured bool `json:"featured,optional"` // 是否精选
|
||||
Status string `json:"status,optional,default=published"` // published, draft
|
||||
}
|
||||
|
||||
// 上传照片响应
|
||||
type UploadAdminPhotoResponse {
|
||||
BaseResponse
|
||||
Data AdminPhoto `json:"data"`
|
||||
}
|
||||
|
||||
// 更新照片请求
|
||||
type UpdateAdminPhotoRequest {
|
||||
Id int64 `path:"id"`
|
||||
Title string `json:"title,optional"`
|
||||
Description string `json:"description,optional"`
|
||||
CategoryId int64 `json:"category_id,optional"`
|
||||
Tags string `json:"tags,optional"`
|
||||
Featured bool `json:"featured,optional"`
|
||||
Status string `json:"status,optional"`
|
||||
}
|
||||
|
||||
// 更新照片响应
|
||||
type UpdateAdminPhotoResponse {
|
||||
BaseResponse
|
||||
Data AdminPhoto `json:"data"`
|
||||
}
|
||||
|
||||
// 删除照片请求
|
||||
type DeleteAdminPhotoRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 删除照片响应
|
||||
type DeleteAdminPhotoResponse {
|
||||
BaseResponse
|
||||
}
|
||||
|
||||
// 设置精选照片请求
|
||||
type SetAdminPhotoFeaturedRequest {
|
||||
Id int64 `path:"id"`
|
||||
Featured bool `json:"featured" validate:"required"`
|
||||
}
|
||||
|
||||
// 设置精选照片响应
|
||||
type SetAdminPhotoFeaturedResponse {
|
||||
BaseResponse
|
||||
Data AdminPhoto `json:"data"`
|
||||
}
|
||||
|
||||
// 批量操作照片请求
|
||||
type BatchAdminPhotoOperationRequest {
|
||||
PhotoIds []int64 `json:"photo_ids" validate:"required"`
|
||||
Operation string `json:"operation" validate:"required"` // publish, draft, delete, set_featured, unset_featured
|
||||
CategoryId int64 `json:"category_id,optional"` // 批量修改分类
|
||||
}
|
||||
|
||||
// 批量操作照片响应
|
||||
type BatchAdminPhotoOperationResponse {
|
||||
BaseResponse
|
||||
Data BatchAdminPhotoOperationData `json:"data"`
|
||||
}
|
||||
|
||||
type BatchAdminPhotoOperationData {
|
||||
SuccessCount int `json:"success_count"`
|
||||
FailedCount int `json:"failed_count"`
|
||||
FailedIds []int64 `json:"failed_ids"`
|
||||
}
|
||||
|
||||
// 照片统计请求
|
||||
type GetAdminPhotoStatsRequest {
|
||||
DateRange string `form:"date_range,optional,default=7d"` // 7d, 30d, 90d
|
||||
}
|
||||
|
||||
// 照片统计响应
|
||||
type GetAdminPhotoStatsResponse {
|
||||
BaseResponse
|
||||
Data AdminPhotoStatsData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminPhotoStatsData {
|
||||
TotalPhotos int64 `json:"total_photos"`
|
||||
PublishedPhotos int64 `json:"published_photos"`
|
||||
DraftPhotos int64 `json:"draft_photos"`
|
||||
FeaturedPhotos int64 `json:"featured_photos"`
|
||||
NewPhotos int64 `json:"new_photos"` // 指定时间范围内新增照片
|
||||
GrowthRate float64 `json:"growth_rate"` // 增长率
|
||||
TotalViews int64 `json:"total_views"` // 总浏览量
|
||||
TotalStorage int64 `json:"total_storage"` // 总存储空间 (字节)
|
||||
}
|
||||
|
||||
// 照片存储信息请求
|
||||
type GetAdminPhotoStorageRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 照片存储信息响应
|
||||
type GetAdminPhotoStorageResponse {
|
||||
BaseResponse
|
||||
Data AdminPhotoStorageData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminPhotoStorageData {
|
||||
OriginalUrl string `json:"original_url"`
|
||||
ThumbnailUrl string `json:"thumbnail_url"`
|
||||
FileSize int64 `json:"file_size"`
|
||||
ThumbnailSize int64 `json:"thumbnail_size"`
|
||||
Format string `json:"format"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
ExifData string `json:"exif_data,optional"` // EXIF 信息 (JSON 格式)
|
||||
}
|
||||
|
||||
// 重新生成缩略图请求
|
||||
type RegenerateAdminPhotoThumbnailRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 重新生成缩略图响应
|
||||
type RegenerateAdminPhotoThumbnailResponse {
|
||||
BaseResponse
|
||||
Data AdminPhotoStorageData `json:"data"`
|
||||
}
|
||||
|
||||
// 管理后台照片管理接口组 - 需要管理员认证
|
||||
@server(
|
||||
group: admin_photos
|
||||
prefix: /admin/photos
|
||||
jwt: AdminAuth
|
||||
)
|
||||
service photography-api {
|
||||
@doc "获取照片列表"
|
||||
@handler getAdminPhotoList
|
||||
get / (GetAdminPhotoListRequest) returns (GetAdminPhotoListResponse)
|
||||
|
||||
@doc "上传照片"
|
||||
@handler uploadAdminPhoto
|
||||
post / (UploadAdminPhotoRequest) returns (UploadAdminPhotoResponse)
|
||||
|
||||
@doc "获取照片详情"
|
||||
@handler getAdminPhoto
|
||||
get /:id (GetAdminPhotoRequest) returns (GetAdminPhotoResponse)
|
||||
|
||||
@doc "更新照片"
|
||||
@handler updateAdminPhoto
|
||||
put /:id (UpdateAdminPhotoRequest) returns (UpdateAdminPhotoResponse)
|
||||
|
||||
@doc "删除照片"
|
||||
@handler deleteAdminPhoto
|
||||
delete /:id (DeleteAdminPhotoRequest) returns (DeleteAdminPhotoResponse)
|
||||
|
||||
@doc "设置精选照片"
|
||||
@handler setAdminPhotoFeatured
|
||||
put /:id/featured (SetAdminPhotoFeaturedRequest) returns (SetAdminPhotoFeaturedResponse)
|
||||
|
||||
@doc "获取照片存储信息"
|
||||
@handler getAdminPhotoStorage
|
||||
get /:id/storage (GetAdminPhotoStorageRequest) returns (GetAdminPhotoStorageResponse)
|
||||
|
||||
@doc "重新生成缩略图"
|
||||
@handler regenerateAdminPhotoThumbnail
|
||||
post /:id/regenerate-thumbnail (RegenerateAdminPhotoThumbnailRequest) returns (RegenerateAdminPhotoThumbnailResponse)
|
||||
|
||||
@doc "批量操作照片"
|
||||
@handler batchAdminPhotoOperation
|
||||
post /batch (BatchAdminPhotoOperationRequest) returns (BatchAdminPhotoOperationResponse)
|
||||
|
||||
@doc "获取照片统计"
|
||||
@handler getAdminPhotoStats
|
||||
get /stats (GetAdminPhotoStatsRequest) returns (GetAdminPhotoStatsResponse)
|
||||
}
|
||||
199
backend/api/desc/admin/users.api
Normal file
199
backend/api/desc/admin/users.api
Normal file
@ -0,0 +1,199 @@
|
||||
syntax = "v1"
|
||||
|
||||
import "common.api"
|
||||
|
||||
// 管理后台用户管理接口
|
||||
|
||||
// 获取用户列表请求
|
||||
type GetAdminUserListRequest {
|
||||
PageRequest
|
||||
Keyword string `form:"keyword,optional"`
|
||||
Status int `form:"status,optional"` // 用户状态筛选
|
||||
SortBy string `form:"sort_by,optional,default=created_at_desc"` // 排序方式
|
||||
}
|
||||
|
||||
// 获取用户列表响应
|
||||
type GetAdminUserListResponse {
|
||||
BaseResponse
|
||||
Data AdminUserListData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminUserListData {
|
||||
PageResponse
|
||||
Users []AdminUser `json:"users"`
|
||||
}
|
||||
|
||||
// 获取用户详情请求
|
||||
type GetAdminUserRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 获取用户详情响应
|
||||
type GetAdminUserResponse {
|
||||
BaseResponse
|
||||
Data AdminUserDetail `json:"data"`
|
||||
}
|
||||
|
||||
// 创建用户请求
|
||||
type CreateAdminUserRequest {
|
||||
Username string `json:"username" validate:"required"`
|
||||
Email string `json:"email" validate:"required,email"`
|
||||
Password string `json:"password" validate:"required,min=6"`
|
||||
Status int `json:"status,optional,default=1"` // 用户状态
|
||||
Role string `json:"role,optional,default=user"` // 用户角色
|
||||
}
|
||||
|
||||
// 创建用户响应
|
||||
type CreateAdminUserResponse {
|
||||
BaseResponse
|
||||
Data AdminUser `json:"data"`
|
||||
}
|
||||
|
||||
// 更新用户请求
|
||||
type UpdateAdminUserRequest {
|
||||
Id int64 `path:"id"`
|
||||
Username string `json:"username,optional"`
|
||||
Email string `json:"email,optional"`
|
||||
Avatar string `json:"avatar,optional"`
|
||||
Status int `json:"status,optional"`
|
||||
Role string `json:"role,optional"`
|
||||
}
|
||||
|
||||
// 更新用户响应
|
||||
type UpdateAdminUserResponse {
|
||||
BaseResponse
|
||||
Data AdminUser `json:"data"`
|
||||
}
|
||||
|
||||
// 删除用户请求
|
||||
type DeleteAdminUserRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 删除用户响应
|
||||
type DeleteAdminUserResponse {
|
||||
BaseResponse
|
||||
}
|
||||
|
||||
// 更新用户状态请求
|
||||
type UpdateAdminUserStatusRequest {
|
||||
Id int64 `path:"id"`
|
||||
Status int `json:"status" validate:"required"` // 1:启用 0:禁用
|
||||
}
|
||||
|
||||
// 更新用户状态响应
|
||||
type UpdateAdminUserStatusResponse {
|
||||
BaseResponse
|
||||
Data AdminUser `json:"data"`
|
||||
}
|
||||
|
||||
// 重置用户密码请求
|
||||
type ResetAdminUserPasswordRequest {
|
||||
Id int64 `path:"id"`
|
||||
NewPassword string `json:"new_password" validate:"required,min=6"`
|
||||
}
|
||||
|
||||
// 重置用户密码响应
|
||||
type ResetAdminUserPasswordResponse {
|
||||
BaseResponse
|
||||
}
|
||||
|
||||
// 上传用户头像请求
|
||||
type UploadAdminUserAvatarRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 上传用户头像响应
|
||||
type UploadAdminUserAvatarResponse {
|
||||
BaseResponse
|
||||
Data UploadAdminUserAvatarData `json:"data"`
|
||||
}
|
||||
|
||||
type UploadAdminUserAvatarData {
|
||||
AvatarUrl string `json:"avatar_url"`
|
||||
}
|
||||
|
||||
// 批量操作用户请求
|
||||
type BatchAdminUserOperationRequest {
|
||||
UserIds []int64 `json:"user_ids" validate:"required"`
|
||||
Operation string `json:"operation" validate:"required"` // enable, disable, delete
|
||||
}
|
||||
|
||||
// 批量操作用户响应
|
||||
type BatchAdminUserOperationResponse {
|
||||
BaseResponse
|
||||
Data BatchAdminUserOperationData `json:"data"`
|
||||
}
|
||||
|
||||
type BatchAdminUserOperationData {
|
||||
SuccessCount int `json:"success_count"`
|
||||
FailedCount int `json:"failed_count"`
|
||||
FailedIds []int64 `json:"failed_ids"`
|
||||
}
|
||||
|
||||
// 用户统计请求
|
||||
type GetAdminUserStatsRequest {
|
||||
DateRange string `form:"date_range,optional,default=7d"` // 7d, 30d, 90d
|
||||
}
|
||||
|
||||
// 用户统计响应
|
||||
type GetAdminUserStatsResponse {
|
||||
BaseResponse
|
||||
Data AdminUserStatsData `json:"data"`
|
||||
}
|
||||
|
||||
type AdminUserStatsData {
|
||||
TotalUsers int64 `json:"total_users"`
|
||||
ActiveUsers int64 `json:"active_users"`
|
||||
InactiveUsers int64 `json:"inactive_users"`
|
||||
NewUsers int64 `json:"new_users"` // 指定时间范围内新增用户
|
||||
GrowthRate float64 `json:"growth_rate"` // 增长率
|
||||
}
|
||||
|
||||
// 管理后台用户管理接口组 - 需要管理员认证
|
||||
@server(
|
||||
group: admin_users
|
||||
prefix: /admin/users
|
||||
jwt: AdminAuth
|
||||
)
|
||||
service photography-api {
|
||||
@doc "获取用户列表"
|
||||
@handler getAdminUserList
|
||||
get / (GetAdminUserListRequest) returns (GetAdminUserListResponse)
|
||||
|
||||
@doc "创建用户"
|
||||
@handler createAdminUser
|
||||
post / (CreateAdminUserRequest) returns (CreateAdminUserResponse)
|
||||
|
||||
@doc "获取用户详情"
|
||||
@handler getAdminUser
|
||||
get /:id (GetAdminUserRequest) returns (GetAdminUserResponse)
|
||||
|
||||
@doc "更新用户"
|
||||
@handler updateAdminUser
|
||||
put /:id (UpdateAdminUserRequest) returns (UpdateAdminUserResponse)
|
||||
|
||||
@doc "删除用户"
|
||||
@handler deleteAdminUser
|
||||
delete /:id (DeleteAdminUserRequest) returns (DeleteAdminUserResponse)
|
||||
|
||||
@doc "更新用户状态"
|
||||
@handler updateAdminUserStatus
|
||||
put /:id/status (UpdateAdminUserStatusRequest) returns (UpdateAdminUserStatusResponse)
|
||||
|
||||
@doc "重置用户密码"
|
||||
@handler resetAdminUserPassword
|
||||
post /:id/reset-password (ResetAdminUserPasswordRequest) returns (ResetAdminUserPasswordResponse)
|
||||
|
||||
@doc "上传用户头像"
|
||||
@handler uploadAdminUserAvatar
|
||||
post /:id/avatar (UploadAdminUserAvatarRequest) returns (UploadAdminUserAvatarResponse)
|
||||
|
||||
@doc "批量操作用户"
|
||||
@handler batchAdminUserOperation
|
||||
post /batch (BatchAdminUserOperationRequest) returns (BatchAdminUserOperationResponse)
|
||||
|
||||
@doc "获取用户统计"
|
||||
@handler getAdminUserStats
|
||||
get /stats (GetAdminUserStatsRequest) returns (GetAdminUserStatsResponse)
|
||||
}
|
||||
Reference in New Issue
Block a user