feat: 完善照片更新和删除业务逻辑
Some checks failed
部署后端服务 / 🚀 构建并部署 (push) Has been cancelled
部署后端服务 / 🔄 回滚部署 (push) Has been cancelled
部署后端服务 / 🧪 测试后端 (push) Has been cancelled

- 实现照片更新功能 (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接口状态
  - 记录技术成果和里程碑
This commit is contained in:
xujiang
2025-07-10 18:08:22 +08:00
parent 317dc170f9
commit 35004f224e
6 changed files with 468 additions and 14 deletions

View File

@ -7,6 +7,7 @@ import (
"photography-backend/internal/logic/photo"
"photography-backend/internal/svc"
"photography-backend/internal/types"
"photography-backend/pkg/response"
)
// 删除照片
@ -20,10 +21,6 @@ func DeletePhotoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := photo.NewDeletePhotoLogic(r.Context(), svcCtx)
resp, err := l.DeletePhoto(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
response.Response(w, resp, err)
}
}

View File

@ -7,6 +7,7 @@ import (
"photography-backend/internal/logic/photo"
"photography-backend/internal/svc"
"photography-backend/internal/types"
"photography-backend/pkg/response"
)
// 更新照片
@ -20,10 +21,6 @@ func UpdatePhotoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := photo.NewUpdatePhotoLogic(r.Context(), svcCtx)
resp, err := l.UpdatePhoto(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
response.Response(w, resp, err)
}
}