feat: 实现用户头像上传功能

- 创建头像上传API接口 (POST /api/v1/users/:id/avatar)
- 实现完整的头像上传逻辑,包含权限验证和文件处理
- 添加头像图片处理功能,支持自动压缩和居中裁剪
- 完善静态文件服务,支持头像访问
- 创建完整的API测试用例
- 更新任务进度文档

任务11已完成,项目完成率提升至37.5%
This commit is contained in:
xujiang
2025-07-11 13:10:04 +08:00
parent d47e55d5fb
commit fa5f7a0ed2
10 changed files with 393 additions and 21 deletions

View File

@ -30,9 +30,9 @@ func main() {
// 添加静态文件服务
server.AddRoute(rest.Route{
Method: http.MethodGet,
Path: "/uploads/:path",
Path: "/uploads/*",
Handler: func(w http.ResponseWriter, r *http.Request) {
http.StripPrefix("/uploads/", http.FileServer(http.Dir(c.FileUpload.UploadDir))).ServeHTTP(w, r)
http.StripPrefix("/uploads/", http.FileServer(http.Dir("uploads"))).ServeHTTP(w, r)
},
})