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接口状态 - 记录技术成果和里程碑
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user