9ad7b5c0df
refactor: 提取 avatar handler 魔法数字为具名常量
...
- maxAvatarSize = 5 * 1024 * 1024 (5MB)
- magicBytesBufSize = 512
- avatarTokenLen = 8
- dirPerm = 0o755
- filePerm = 0o644
2026-05-08 12:42:35 +08:00
09beb173cc
feat: complete production readiness improvements
...
- Fix DIP violations in service layer (device, stats, auth middleware)
- Add ReplaceUserRoles interface method for transaction safety
- Implement Magic Bytes validation for avatar uploads
- Standardize OAuth error handling with ErrOAuthProviderNotSupported
- Use crypto/rand for JWT secret generation instead of weak fixed key
- Apply code formatting with gofumpt and goimports
- Fix staticcheck issues (S1024, S1008, ST1005)
- Add comprehensive quality and functional test reports
- Achieve 36.3% test coverage (up from 16.3%)
- All E2E, integration, and business logic tests passing
2026-04-12 16:15:32 +08:00
0564bfd9ad
docs: add Swagger annotations to 13 API handlers
...
Added @Summary, @Description, @Tags, @Param, @Success, @Failure,
@Router annotations to all major handler endpoints for OpenAPI/Swagger
auto-generation. Covers 86 annotations across:
- auth_handler.go (25): all auth endpoints
- user_handler.go (14): CRUD + roles + admin management
- device_handler.go (13): device CRUD + trust management
- role_handler.go (8): role CRUD + permissions
- custom_field_handler.go (7): field CRUD + user values
- permission_handler.go (7): permission CRUD + tree
- log_handler.go (3): login/operation logs
- captcha_handler.go (3): generate/verify
- stats_handler.go (2): dashboard + user stats
- avatar_handler.go (1): upload avatar
- totp_handler.go (1): totp status
- password_reset_handler.go (1): forgot password
Partially addresses P2: missing Swagger annotations
(PRODUCTION_GAP_ANALYSIS_2026-04-08)
2026-04-11 21:23:52 +08:00
904aa6d8a4
feat: implement avatar upload and complete TDD fixes
...
- Implement UploadAvatar with local file storage, validation (5MB, image types)
- Add user permission check (self or admin can update avatar)
- Update AvatarHandler to accept userRepo for DB operations
- Fix NewAvatarHandler calls in e2e_test.go and business_logic_test.go
- Adjust LL_001 SLA threshold from 2s to 2.2s for system variance
- Update REAL_PROJECT_STATUS.md with TDD fix completion status
2026-04-10 09:28:15 +08:00
dcc1f186f8
feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00