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:
99
backend/api/desc/user.api
Normal file
99
backend/api/desc/user.api
Normal file
@ -0,0 +1,99 @@
|
||||
syntax = "v1"
|
||||
|
||||
import "common.api"
|
||||
|
||||
// 用户管理接口
|
||||
|
||||
// 获取用户列表请求
|
||||
type GetUserListRequest {
|
||||
PageRequest
|
||||
Keyword string `form:"keyword,optional"`
|
||||
}
|
||||
|
||||
// 获取用户列表响应
|
||||
type GetUserListResponse {
|
||||
BaseResponse
|
||||
Data UserListData `json:"data"`
|
||||
}
|
||||
|
||||
type UserListData {
|
||||
PageResponse
|
||||
Users []User `json:"users"`
|
||||
}
|
||||
|
||||
// 获取用户详情请求
|
||||
type GetUserRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 获取用户详情响应
|
||||
type GetUserResponse {
|
||||
BaseResponse
|
||||
Data User `json:"data"`
|
||||
}
|
||||
|
||||
// 创建用户请求
|
||||
type CreateUserRequest {
|
||||
Username string `json:"username" validate:"required"`
|
||||
Email string `json:"email" validate:"required,email"`
|
||||
Password string `json:"password" validate:"required,min=6"`
|
||||
}
|
||||
|
||||
// 创建用户响应
|
||||
type CreateUserResponse {
|
||||
BaseResponse
|
||||
Data User `json:"data"`
|
||||
}
|
||||
|
||||
// 更新用户请求
|
||||
type UpdateUserRequest {
|
||||
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 {
|
||||
BaseResponse
|
||||
Data User `json:"data"`
|
||||
}
|
||||
|
||||
// 删除用户请求
|
||||
type DeleteUserRequest {
|
||||
Id int64 `path:"id"`
|
||||
}
|
||||
|
||||
// 删除用户响应
|
||||
type DeleteUserResponse {
|
||||
BaseResponse
|
||||
}
|
||||
|
||||
// 用户管理接口组
|
||||
@server(
|
||||
group: user
|
||||
prefix: /api/v1/users
|
||||
jwt: Auth
|
||||
)
|
||||
service photography-api {
|
||||
@doc "获取用户列表"
|
||||
@handler getUserList
|
||||
get / (GetUserListRequest) returns (GetUserListResponse)
|
||||
|
||||
@doc "创建用户"
|
||||
@handler createUser
|
||||
post / (CreateUserRequest) returns (CreateUserResponse)
|
||||
|
||||
@doc "获取用户详情"
|
||||
@handler getUser
|
||||
get /:id (GetUserRequest) returns (GetUserResponse)
|
||||
|
||||
@doc "更新用户"
|
||||
@handler updateUser
|
||||
put /:id (UpdateUserRequest) returns (UpdateUserResponse)
|
||||
|
||||
@doc "删除用户"
|
||||
@handler deleteUser
|
||||
delete /:id (DeleteUserRequest) returns (DeleteUserResponse)
|
||||
}
|
||||
Reference in New Issue
Block a user