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

@ -17,11 +17,6 @@ import (
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
server.AddRoutes(
[]rest.Route{},
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
)
server.AddRoutes(
[]rest.Route{
{
@ -158,6 +153,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/:id",
Handler: user.DeleteUserHandler(serverCtx),
},
{
// 上传用户头像
Method: http.MethodPost,
Path: "/:id/avatar",
Handler: user.UploadAvatarHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
rest.WithPrefix("/api/v1/users"),