feat: implement room creation and management (Part 5) - #10
Conversation
|
整体功能基本可以接受,本地测试通过。不过还有几个点建议继续处理或至少在后续合并前明确:
|
|
Group 3 auth/user-profile implementation is now available in #15. That PR adds the real context-based current-user flow:
After #15 is merged, this PR should be able to drop the temporary |
- Add middleware/auth.go (RequireAuth/CurrentUser/AuthByRoute) - Replace X-Mock-User-ID with AuthByRoute in router.go - Sync user_service.go with upstream Group 3 implementation - Add UpdateProfileWithAudit to user_repository - Allow owner to update room in 'full' status - Auto-transition full→recruiting when capacity expanded - Use crypto/rand for invite_code generation
概述
实现5组(房间创建与房间管理)全部后端 service 层功能,同时补全3组和6组依赖的 service stub,确保项目可编译运行。
5组接口
/rooms/rooms/{id}/rooms/{id}/close修改文件
internal/api/router.gointernal/service/room_service.gointernal/service/user_service.gointernal/repository/room_repository.go5组需求逐项实现
POST /rooms - 创建房间
PUT /rooms/{id} - 修改房间
POST /rooms/{id}/close - 关闭房间
Review 修复明细
1. GetCurrent 固定取第一条用户 → 改为可切换
X-Mock-User-IDHTTP Header 注入 contextcurl -H "X-Mock-User-ID: 3" ...即可切换用户2. 创建房间非事务 → 改为事务
CreateRoomWithOwner()repository 方法db.Transaction()确保 room + owner member 原子写入3. need_reservation 和 reservation_status 不同步
4. 枚举字段无校验 → 增加校验
isValidVisibility()和isValidJoinMode()校验函数public,privatedirect,approval,invite_only5. member_limit 无有效性校验 → 增加校验
6. PR 范围超出5组 → 代码标注