feat: 完成后端服务核心业务逻辑实现

## 主要功能
-  用户认证模块 (登录/注册/JWT)
-  照片管理模块 (上传/查询/分页/搜索)
-  分类管理模块 (创建/查询/分页)
-  用户管理模块 (用户列表/分页查询)
-  健康检查接口

## 技术实现
- 基于 go-zero v1.8.0 标准架构
- Handler → Logic → Model 三层架构
- SQLite/PostgreSQL 数据库支持
- JWT 认证机制
- bcrypt 密码加密
- 统一响应格式
- 自定义模型方法 (分页/搜索)

## API 接口
- POST /api/v1/auth/login - 用户登录
- POST /api/v1/auth/register - 用户注册
- GET /api/v1/health - 健康检查
- GET /api/v1/photos - 照片列表
- POST /api/v1/photos - 上传照片
- GET /api/v1/categories - 分类列表
- POST /api/v1/categories - 创建分类
- GET /api/v1/users - 用户列表

## 配置完成
- 开发环境配置 (SQLite)
- 生产环境支持 (PostgreSQL)
- JWT 认证配置
- 文件上传配置
- Makefile 构建脚本

服务已验证可正常构建和启动。
This commit is contained in:
xujiang
2025-07-10 16:12:12 +08:00
parent 39a42695d3
commit 1e828e03fe
144 changed files with 3669 additions and 20721 deletions

View File

@ -0,0 +1,242 @@
// Code generated by goctl. DO NOT EDIT.
// goctl 1.8.4
package types
type BaseResponse struct {
Code int `json:"code"`
Message string `json:"message"`
}
type Category struct {
Id int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
type CategoryListData struct {
PageResponse
Categories []Category `json:"categories"`
}
type CreateCategoryRequest struct {
Name string `json:"name" validate:"required"`
Description string `json:"description,optional"`
}
type CreateCategoryResponse struct {
BaseResponse
Data Category `json:"data"`
}
type CreateUserRequest struct {
Username string `json:"username" validate:"required"`
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,min=6"`
}
type CreateUserResponse struct {
BaseResponse
Data User `json:"data"`
}
type DeleteCategoryRequest struct {
Id int64 `path:"id"`
}
type DeleteCategoryResponse struct {
BaseResponse
}
type DeletePhotoRequest struct {
Id int64 `path:"id"`
}
type DeletePhotoResponse struct {
BaseResponse
}
type DeleteUserRequest struct {
Id int64 `path:"id"`
}
type DeleteUserResponse struct {
BaseResponse
}
type GetCategoryListRequest struct {
PageRequest
Keyword string `form:"keyword,optional"`
}
type GetCategoryListResponse struct {
BaseResponse
Data CategoryListData `json:"data"`
}
type GetCategoryRequest struct {
Id int64 `path:"id"`
}
type GetCategoryResponse struct {
BaseResponse
Data Category `json:"data"`
}
type GetPhotoListRequest struct {
PageRequest
CategoryId int64 `form:"category_id,optional"`
UserId int64 `form:"user_id,optional"`
Keyword string `form:"keyword,optional"`
}
type GetPhotoListResponse struct {
BaseResponse
Data PhotoListData `json:"data"`
}
type GetPhotoRequest struct {
Id int64 `path:"id"`
}
type GetPhotoResponse struct {
BaseResponse
Data Photo `json:"data"`
}
type GetUserListRequest struct {
PageRequest
Keyword string `form:"keyword,optional"`
}
type GetUserListResponse struct {
BaseResponse
Data UserListData `json:"data"`
}
type GetUserRequest struct {
Id int64 `path:"id"`
}
type GetUserResponse struct {
BaseResponse
Data User `json:"data"`
}
type LoginData struct {
Token string `json:"token"`
User User `json:"user"`
}
type LoginRequest struct {
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
}
type LoginResponse struct {
BaseResponse
Data LoginData `json:"data"`
}
type PageRequest struct {
Page int `form:"page,default=1"`
PageSize int `form:"page_size,default=10"`
}
type PageResponse struct {
Total int64 `json:"total"`
Page int `json:"page"`
Size int `json:"size"`
}
type Photo struct {
Id int64 `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
FilePath string `json:"file_path"`
ThumbnailPath string `json:"thumbnail_path"`
UserId int64 `json:"user_id"`
CategoryId int64 `json:"category_id"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
type PhotoListData struct {
PageResponse
Photos []Photo `json:"photos"`
}
type RegisterRequest struct {
Username string `json:"username" validate:"required"`
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,min=6"`
}
type RegisterResponse struct {
BaseResponse
Data User `json:"data"`
}
type UpdateCategoryRequest struct {
Id int64 `path:"id"`
Name string `json:"name,optional"`
Description string `json:"description,optional"`
}
type UpdateCategoryResponse struct {
BaseResponse
Data Category `json:"data"`
}
type UpdatePhotoRequest struct {
Id int64 `path:"id"`
Title string `json:"title,optional"`
Description string `json:"description,optional"`
CategoryId int64 `json:"category_id,optional"`
}
type UpdatePhotoResponse struct {
BaseResponse
Data Photo `json:"data"`
}
type UpdateUserRequest struct {
Id int64 `path:"id"`
Username string `json:"username,optional"`
Email string `json:"email,optional"`
Avatar string `json:"avatar,optional"`
Status int `json:"status,optional"`
}
type UpdateUserResponse struct {
BaseResponse
Data User `json:"data"`
}
type UploadPhotoRequest struct {
Title string `json:"title" validate:"required"`
Description string `json:"description,optional"`
CategoryId int64 `json:"category_id" validate:"required"`
}
type UploadPhotoResponse struct {
BaseResponse
Data Photo `json:"data"`
}
type User struct {
Id int64 `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Avatar string `json:"avatar"`
Status int `json:"status"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
type UserListData struct {
PageResponse
Users []User `json:"users"`
}