Files
photography/backend/test_api.http
xujiang a2f2f66f88
Some checks failed
部署后端服务 / 🧪 测试后端 (push) Failing after 1m37s
部署后端服务 / 🚀 构建并部署 (push) Has been skipped
部署后端服务 / 🔄 回滚部署 (push) Has been skipped
refactor: 重构后端架构,采用 Go 风格四层设计模式
## 主要变更

### 🏗️ 架构重构
- 采用简洁的四层架构:API → Service → Repository → Model
- 遵循 Go 语言最佳实践和命名规范
- 实现依赖注入和接口导向设计
- 统一错误处理和响应格式

### 📁 目录结构优化
- 删除重复模块 (application/, domain/, infrastructure/ 等)
- 规范化命名 (使用 Go 风格的 snake_case)
- 清理无关文件 (package.json, node_modules/ 等)
- 新增规范化的测试目录结构

### 📚 文档系统
- 为每个模块创建详细的 CLAUDE.md 指导文件
- 包含开发规范、最佳实践和使用示例
- 支持模块化开发,缩短上下文长度

### 🔧 开发规范
- 统一接口命名规范 (UserServicer, PhotoRepositoryr)
- 标准化错误处理机制
- 完善的测试策略 (单元测试、集成测试、性能测试)
- 规范化的配置管理

### 🗂️ 新增文件
- cmd/server/ - 服务启动入口和配置
- internal/model/ - 数据模型层 (entity, dto, request)
- pkg/ - 共享工具包 (logger, response, validator)
- tests/ - 完整测试结构
- docs/ - API 文档和架构设计
- .gitignore - Git 忽略文件配置

### 🗑️ 清理内容
- 删除 Node.js 相关文件 (package.json, node_modules/)
- 移除重复的架构目录
- 清理临时文件和构建产物
- 删除重复的文档文件

## 影响
- 提高代码可维护性和可扩展性
- 统一开发规范,提升团队协作效率
- 优化项目结构,符合 Go 语言生态标准
- 完善文档体系,降低上手难度
2025-07-10 11:20:59 +08:00

116 lines
2.4 KiB
HTTP

# Photography Backend API
###
GET http://localhost:8080/health
###
GET http://localhost:8080/stats
###
POST http://localhost:8080/api/v1/auth/register
Content-Type: application/json
{
"username": "testuser",
"email": "test@example.com",
"password": "password123",
"name": ""
}
###
POST http://localhost:8080/api/v1/auth/login
Content-Type: application/json
{
"username": "testuser",
"password": "password123"
}
###
GET http://localhost:8080/api/v1/users
###
POST http://localhost:8080/api/v1/users
Content-Type: application/json
{
"username": "newuser",
"email": "newuser@example.com",
"password": "password123",
"name": "",
"role": "user"
}
###
GET http://localhost:8080/api/v1/categories
###
POST http://localhost:8080/api/v1/categories
Content-Type: application/json
{
"name": "",
"description": "",
"user_id": 1,
"color": "#10B981"
}
###
GET http://localhost:8080/api/v1/tags
###
POST http://localhost:8080/api/v1/tags
Content-Type: application/json
{
"name": "",
"description": "",
"user_id": 1,
"color": "#10B981"
}
###
GET http://localhost:8080/api/v1/albums
###
POST http://localhost:8080/api/v1/albums
Content-Type: application/json
{
"title": "",
"description": "",
"user_id": 1,
"is_public": true
}
###
GET http://localhost:8080/api/v1/photos
###
POST http://localhost:8080/api/v1/photos
Content-Type: application/json
{
"title": "",
"description": "",
"filename": "sunrise.jpg",
"original_url": "http://localhost:8080/uploads/photos/sunrise.jpg",
"file_size": 1024000,
"mime_type": "image/jpeg",
"user_id": 1,
"category_id": 1
}
### (使)
# POST http://localhost:8080/api/v1/upload/photo
# Content-Type: multipart/form-data
# Authorization: Bearer YOUR_JWT_TOKEN
#
# photo: []
# title:
# description:
# category_id: 1
### ()
# GET http://localhost:8080/api/v1/upload/stats
# Authorization: Bearer ADMIN_JWT_TOKEN