🚀 主要功能: - 完善后端API服务层,实现完整的CRUD操作 - 开发管理后台所有核心页面 (仪表板、照片、分类、标签、用户、设置) - 完成前后端完全集成,所有API接口正常对接 - 配置完整的CI/CD流水线,支持自动化部署 🎯 后端完善: - 实现PhotoService, CategoryService, TagService, UserService - 添加完整的API处理器和路由配置 - 支持Docker容器化部署 - 添加数据库迁移和健康检查 🎨 管理后台完成: - 仪表板: 实时统计数据展示 - 照片管理: 完整的CRUD操作,支持批量处理 - 分类管理: 树形结构展示和管理 - 标签管理: 颜色标签和统计信息 - 用户管理: 角色权限控制 - 系统设置: 多标签配置界面 - 添加pre-commit代码质量检查 🔧 部署配置: - Docker Compose完整配置 - 后端CI/CD流水线 (Docker部署) - 管理后台CI/CD流水线 (静态文件部署) - 前端CI/CD流水线优化 - 自动化脚本: 部署、备份、监控 - 完整的部署文档和运维指南 ✅ 集成完成: - 所有API接口正常连接 - 认证系统完整集成 - 数据获取和状态管理 - 错误处理和用户反馈 - 响应式设计优化
242 lines
7.5 KiB
Go
242 lines
7.5 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// 通用请求和响应结构
|
|
|
|
// ErrorResponse 错误响应
|
|
type ErrorResponse struct {
|
|
Error string `json:"error"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// SuccessResponse 成功响应
|
|
type SuccessResponse struct {
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// BatchDeleteRequest 批量删除请求
|
|
type BatchDeleteRequest struct {
|
|
IDs []uint `json:"ids" binding:"required,min=1"`
|
|
}
|
|
|
|
// GenerateSlugRequest 生成slug请求
|
|
type GenerateSlugRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
}
|
|
|
|
// GenerateSlugResponse 生成slug响应
|
|
type GenerateSlugResponse struct {
|
|
Slug string `json:"slug"`
|
|
}
|
|
|
|
// 照片相关请求
|
|
|
|
// CreatePhotoRequest 创建照片请求
|
|
type CreatePhotoRequest struct {
|
|
Title string `json:"title" binding:"required"`
|
|
Description string `json:"description"`
|
|
OriginalFilename string `json:"original_filename"`
|
|
FileSize int64 `json:"file_size"`
|
|
Status string `json:"status" binding:"oneof=draft published archived processing"`
|
|
CategoryIDs []uint `json:"category_ids"`
|
|
TagIDs []uint `json:"tag_ids"`
|
|
Camera string `json:"camera"`
|
|
Lens string `json:"lens"`
|
|
ISO int `json:"iso"`
|
|
Aperture string `json:"aperture"`
|
|
ShutterSpeed string `json:"shutter_speed"`
|
|
FocalLength string `json:"focal_length"`
|
|
TakenAt *time.Time `json:"taken_at"`
|
|
}
|
|
|
|
// UpdatePhotoRequest 更新照片请求
|
|
type UpdatePhotoRequest struct {
|
|
Title *string `json:"title"`
|
|
Description *string `json:"description"`
|
|
Status *string `json:"status" binding:"omitempty,oneof=draft published archived processing"`
|
|
CategoryIDs *[]uint `json:"category_ids"`
|
|
TagIDs *[]uint `json:"tag_ids"`
|
|
Camera *string `json:"camera"`
|
|
Lens *string `json:"lens"`
|
|
ISO *int `json:"iso"`
|
|
Aperture *string `json:"aperture"`
|
|
ShutterSpeed *string `json:"shutter_speed"`
|
|
FocalLength *string `json:"focal_length"`
|
|
TakenAt *time.Time `json:"taken_at"`
|
|
}
|
|
|
|
// BatchUpdatePhotosRequest 批量更新照片请求
|
|
type BatchUpdatePhotosRequest struct {
|
|
IDs []uint `json:"ids" binding:"required,min=1"`
|
|
Status *string `json:"status" binding:"omitempty,oneof=draft published archived processing"`
|
|
CategoryIDs *[]uint `json:"category_ids"`
|
|
TagIDs *[]uint `json:"tag_ids"`
|
|
}
|
|
|
|
// PhotoStats 照片统计信息
|
|
type PhotoStats struct {
|
|
Total int64 `json:"total"`
|
|
ThisMonth int64 `json:"this_month"`
|
|
Today int64 `json:"today"`
|
|
TotalSize int64 `json:"total_size"`
|
|
StatusStats map[string]int64 `json:"status_stats"`
|
|
}
|
|
|
|
// 分类相关请求
|
|
|
|
// CreateCategoryRequest 创建分类请求
|
|
type CreateCategoryRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
Slug string `json:"slug" binding:"required"`
|
|
Description string `json:"description"`
|
|
ParentID *uint `json:"parent_id"`
|
|
}
|
|
|
|
// UpdateCategoryRequest 更新分类请求
|
|
type UpdateCategoryRequest struct {
|
|
Name *string `json:"name"`
|
|
Slug *string `json:"slug"`
|
|
Description *string `json:"description"`
|
|
ParentID *uint `json:"parent_id"`
|
|
SortOrder *int `json:"sort_order"`
|
|
IsActive *bool `json:"is_active"`
|
|
}
|
|
|
|
// ReorderCategoriesRequest 重新排序分类请求
|
|
type ReorderCategoriesRequest struct {
|
|
ParentID *uint `json:"parent_id"`
|
|
CategoryIDs []uint `json:"category_ids" binding:"required,min=1"`
|
|
}
|
|
|
|
// CategoryStats 分类统计信息
|
|
type CategoryStats struct {
|
|
Total int64 `json:"total"`
|
|
Active int64 `json:"active"`
|
|
TopLevel int64 `json:"top_level"`
|
|
PhotoCounts map[string]int64 `json:"photo_counts"`
|
|
}
|
|
|
|
// CategoryTree 分类树结构
|
|
type CategoryTree struct {
|
|
ID uint `json:"id"`
|
|
Name string `json:"name"`
|
|
Slug string `json:"slug"`
|
|
Description string `json:"description"`
|
|
ParentID *uint `json:"parent_id"`
|
|
SortOrder int `json:"sort_order"`
|
|
IsActive bool `json:"is_active"`
|
|
PhotoCount int64 `json:"photo_count"`
|
|
Children []CategoryTree `json:"children"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// 标签相关请求
|
|
|
|
// CreateTagRequest 创建标签请求
|
|
type CreateTagRequest struct {
|
|
Name string `json:"name" binding:"required"`
|
|
Slug string `json:"slug" binding:"required"`
|
|
Description string `json:"description"`
|
|
Color string `json:"color"`
|
|
}
|
|
|
|
// UpdateTagRequest 更新标签请求
|
|
type UpdateTagRequest struct {
|
|
Name *string `json:"name"`
|
|
Slug *string `json:"slug"`
|
|
Description *string `json:"description"`
|
|
Color *string `json:"color"`
|
|
IsActive *bool `json:"is_active"`
|
|
}
|
|
|
|
// TagStats 标签统计信息
|
|
type TagStats struct {
|
|
Total int64 `json:"total"`
|
|
Active int64 `json:"active"`
|
|
Used int64 `json:"used"`
|
|
Unused int64 `json:"unused"`
|
|
AvgPhotosPerTag float64 `json:"avg_photos_per_tag"`
|
|
}
|
|
|
|
// TagWithCount 带照片数量的标签
|
|
type TagWithCount struct {
|
|
Tag
|
|
PhotoCount int64 `json:"photo_count"`
|
|
}
|
|
|
|
// TagCloudItem 标签云项目
|
|
type TagCloudItem struct {
|
|
Name string `json:"name"`
|
|
Slug string `json:"slug"`
|
|
Color string `json:"color"`
|
|
Count int64 `json:"count"`
|
|
}
|
|
|
|
// 用户相关请求
|
|
|
|
// CreateUserRequest 创建用户请求
|
|
type CreateUserRequest struct {
|
|
Username string `json:"username" binding:"required,min=3,max=50"`
|
|
Email string `json:"email" binding:"required,email"`
|
|
Password string `json:"password" binding:"required,min=8"`
|
|
Role string `json:"role" binding:"oneof=user editor admin"`
|
|
}
|
|
|
|
// UpdateUserRequest 更新用户请求
|
|
type UpdateUserRequest struct {
|
|
Username *string `json:"username" binding:"omitempty,min=3,max=50"`
|
|
Email *string `json:"email" binding:"omitempty,email"`
|
|
Role *string `json:"role" binding:"omitempty,oneof=user editor admin"`
|
|
IsActive *bool `json:"is_active"`
|
|
}
|
|
|
|
// UpdateCurrentUserRequest 更新当前用户请求
|
|
type UpdateCurrentUserRequest struct {
|
|
Username *string `json:"username" binding:"omitempty,min=3,max=50"`
|
|
Email *string `json:"email" binding:"omitempty,email"`
|
|
}
|
|
|
|
// ChangePasswordRequest 修改密码请求
|
|
type ChangePasswordRequest struct {
|
|
OldPassword string `json:"old_password" binding:"required"`
|
|
NewPassword string `json:"new_password" binding:"required,min=8"`
|
|
}
|
|
|
|
// LoginRequest 登录请求
|
|
type LoginRequest struct {
|
|
Username string `json:"username" binding:"required"`
|
|
Password string `json:"password" binding:"required"`
|
|
}
|
|
|
|
// LoginResponse 登录响应
|
|
type LoginResponse struct {
|
|
User *UserResponse `json:"user"`
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
ExpiresIn int64 `json:"expires_in"`
|
|
}
|
|
|
|
// RefreshTokenRequest 刷新token请求
|
|
type RefreshTokenRequest struct {
|
|
RefreshToken string `json:"refresh_token" binding:"required"`
|
|
}
|
|
|
|
// RefreshTokenResponse 刷新token响应
|
|
type RefreshTokenResponse struct {
|
|
AccessToken string `json:"access_token"`
|
|
RefreshToken string `json:"refresh_token"`
|
|
ExpiresIn int64 `json:"expires_in"`
|
|
}
|
|
|
|
// UserResponse 用户响应(隐藏敏感信息)
|
|
type UserResponse struct {
|
|
ID uint `json:"id"`
|
|
Username string `json:"username"`
|
|
Email string `json:"email"`
|
|
Role string `json:"role"`
|
|
IsActive bool `json:"is_active"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
} |