Files
photography/backend/test_photo_crud.http
xujiang 5cbdc5af73 feat: 完善照片更新和删除业务逻辑
- 实现照片更新功能 (updatePhotoLogic.go)
  - 支持部分字段更新 (title, description, category_id)
  - 添加用户权限验证,只能更新自己的照片
  - 添加分类存在性验证
  - 完善错误处理和响应格式

- 实现照片删除功能 (deletePhotoLogic.go)
  - 添加用户权限验证,只能删除自己的照片
  - 同时删除数据库记录和文件系统文件
  - 安全的文件删除处理

- 更新Handler使用统一响应格式
  - updatePhotoHandler.go: 使用response.Response统一处理
  - deletePhotoHandler.go: 使用response.Response统一处理

- 添加完整API测试用例 (test_photo_crud.http)
  - 涵盖正常场景和错误场景测试
  - 包含权限验证测试

- 更新项目进度 (TASK_PROGRESS.md)
  - 完成率从8%提升到12%
  - 更新API接口状态
  - 记录技术成果和里程碑
2025-07-10 18:08:22 +08:00

94 lines
2.1 KiB
HTTP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### CRUD
### 1. token
POST http://localhost:8888/api/v1/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "123456"
}
###
@token = {{login.response.body.data.token}}
### 2.
GET http://localhost:8888/api/v1/photos?page=1&page_size=5
Authorization: Bearer {{token}}
### 3. ()
POST http://localhost:8888/api/v1/photos
Authorization: Bearer {{token}}
Content-Type: multipart/form-data; boundary=boundary
--boundary
Content-Disposition: form-data; name="title"
--boundary
Content-Disposition: form-data; name="description"
--boundary
Content-Disposition: form-data; name="category_id"
1
--boundary
Content-Disposition: form-data; name="file"; filename="test.jpg"
Content-Type: image/jpeg
< ./test.jpg
--boundary--
### 4.
GET http://localhost:8888/api/v1/photos/1
Authorization: Bearer {{token}}
### 5.
PUT http://localhost:8888/api/v1/photos/1
Authorization: Bearer {{token}}
Content-Type: application/json
{
"title": "",
"description": "",
"category_id": 1
}
### 6.
GET http://localhost:8888/api/v1/photos/1
Authorization: Bearer {{token}}
### 7.
DELETE http://localhost:8888/api/v1/photos/1
Authorization: Bearer {{token}}
### 8. 404
GET http://localhost:8888/api/v1/photos/1
Authorization: Bearer {{token}}
###
### 9.
PUT http://localhost:8888/api/v1/photos/999
Authorization: Bearer {{token}}
Content-Type: application/json
{
"title": ""
}
### 10.
DELETE http://localhost:8888/api/v1/photos/999
Authorization: Bearer {{token}}
### 11.
PUT http://localhost:8888/api/v1/photos/1
Content-Type: application/json
{
"title": ""
}
### 12.
DELETE http://localhost:8888/api/v1/photos/1