feat(phase2e-2): Go meeting 模块 DDL + Model + DAO + service/controller/router 骨架(Task 3+4)

Task 3 - 数据库与持久化层:
- init.sql 追加 3 张表(meeting_rooms / meeting_participants / meeting_chats)+ 9 索引 + 全量 COMMENT
- 新增 phase2e2_migration.sql 增量升级脚本(IF NOT EXISTS 幂等)
- app/constants/meeting.go 统一会议常量(类型/状态/角色/结束原因/离会原因/默认配置/WS 事件 8 组)
- app/meeting/model 3 个 model + GORM tag(TIMESTAMP(0) 对齐现有表风格)
- app/meeting/dao 3 个 DAO 共 24 个方法:
  * meeting_room_dao:Create/Get/Exists/MarkStarted/MarkEnded(乐观锁)/UpdateHost/UpdateSettings/ListByHost/ListExpiredForCleanup
  * meeting_participant_dao:JoinRoom(事务内复用旧记录)/LeaveRoom(EXTRACT(EPOCH) DB 时间)/LeaveAllActive/TransferHost(事务)/FindActiveByUser(JOIN 单点校验)/列表计数更新
  * meeting_chat_dao:Create/ListByRoom(游标)/DeleteByRoomIDs/CountByRoom
- psql 真库跑通 CRUD + UNIQUE + CASCADE + 主持人转让事务 + duration=10s 精确匹配 8 场景

Task 4 - Go 侧 service/controller/router/wire 骨架:
- app/meeting/service/interfaces.go:NotifyPusher / UserInfoResolver / OnlineChecker 三接口(解耦 notify/contact/ws)
- app/meeting/service/meeting_service.go:MeetingService + 8 sentinel error + 17 个空方法(返回 ErrNotImplemented)
- app/meeting/controller/meeting_controller.go:12 个 Gin handler + responseNotImplemented(501)
- app/meeting/router.go:12 条路由挂 /api/v1/meeting/* 并套 jwtAuth(扁平化 router.go,与 group/notify 一致)
- app/meeting/provider.go:MeetingSet = wire.NewSet(DAO×3, Service, Controller)
- 全局 wire.go 挂入 MeetingSet + 3 条 wire.Bind(Notify/UserInfo/Online);App struct/NewApp 加字段;router/router.go 挂载
- 存量修复:admin/provider.go 补齐 MessageManage{DAO,Service,Controller} 解决旧版 wire 重生成报 no provider found
- 验证:go build ./... / go vet ./... / wire ./app/provider 零错误;GIN_MODE=debug 启动打印全部 12 条路由;无 token curl 3 条代表性路由均返回 401(JWT 中间件生效)

关键风格修正(偏离草案):
- 常量归入 app/constants/meeting.go 单文件(与 group.go / notify.go 同构),非草案 app/meeting/constants/
- TIMESTAMP(0) 取代草案 TIMESTAMPTZ 对齐所有现有表
- 冗余 idx_meeting_rooms_code 移除(UNIQUE 已自动建索引)
- router/provider 目录扁平化(app/meeting/router.go / app/meeting/provider.go)
- 延续项目 Go 侧"零 _test.go"风格,用代码审查 + psql 真库验证 + Playwright E2E 三层守护

文档同步:
- docs/progress/CURRENT_STATUS.md 新增 Task 3 / Task 4 交付段落
- .cursor/rules/project-context.mdc Phase 2e-2 进度推进至 Task 0-4 
- docs/plans/2026-04-21-phase2e-2-implementation.plan.md Task 3 / Task 4 标记完成 + 实际产出 vs 计划差异

Made-with: Cursor
This commit is contained in:
bujinyuan
2026-04-21 16:04:57 +08:00
parent 6e2e792db0
commit d22f61fb9b
23 changed files with 1474 additions and 70 deletions

View File

@@ -15,17 +15,20 @@ import (
"github.com/echochat/backend/app/auth/service"
controller3 "github.com/echochat/backend/app/contact/controller"
dao3 "github.com/echochat/backend/app/contact/dao"
service3 "github.com/echochat/backend/app/contact/service"
service4 "github.com/echochat/backend/app/contact/service"
controller4 "github.com/echochat/backend/app/file/controller"
service4 "github.com/echochat/backend/app/file/service"
service5 "github.com/echochat/backend/app/file/service"
controller5 "github.com/echochat/backend/app/group/controller"
dao4 "github.com/echochat/backend/app/group/dao"
service5 "github.com/echochat/backend/app/group/service"
imApp "github.com/echochat/backend/app/im"
service6 "github.com/echochat/backend/app/group/service"
"github.com/echochat/backend/app/im"
controller7 "github.com/echochat/backend/app/meeting/controller"
dao6 "github.com/echochat/backend/app/meeting/dao"
service7 "github.com/echochat/backend/app/meeting/service"
controller6 "github.com/echochat/backend/app/notify/controller"
dao5 "github.com/echochat/backend/app/notify/dao"
service6 "github.com/echochat/backend/app/notify/service"
task2 "github.com/echochat/backend/app/notify/task"
service3 "github.com/echochat/backend/app/notify/service"
"github.com/echochat/backend/app/notify/task"
"github.com/echochat/backend/app/ws"
"github.com/echochat/backend/config"
"github.com/echochat/backend/pkg/db"
@@ -69,46 +72,37 @@ func InitializeApp(cfg *config.Config) (*App, error) {
onlineController := controller2.NewOnlineController(onlineManageService)
contactManageService := service2.NewContactManageService(gormDB)
contactManageController := controller2.NewContactManageController(contactManageService)
handler := ws.ProvideWSHandler(hub, pubSub, jwtConfig, onlineService, authService)
friendGroupDAO := dao3.NewFriendGroupDAO(gormDB)
// Notify 模块初始化contact/group 依赖 NotifyPusher
notificationDAO := dao5.NewNotificationDAO(gormDB)
notifyService := service6.NewNotifyService(notificationDAO, pubSub, friendshipDAO)
notificationController := controller6.NewNotificationController(notifyService)
notifyCleanupTask := task2.NewCleanupTask(notificationDAO)
contactService := service3.NewContactService(friendshipDAO, friendGroupDAO, onlineService, notifyService)
contactController := controller3.NewContactController(contactService)
// IM 模块初始化
conversationDAO := imApp.ProvideConversationDAO(gormDB)
messageDAO := imApp.ProvideMessageDAO(gormDB)
groupDAO := dao4.NewGroupDAO(gormDB)
messageReadDAO := dao4.NewMessageReadDAO(gormDB)
imService := imApp.ProvideIMService(conversationDAO, messageDAO, pubSub, client, friendshipDAO, friendshipDAO, groupDAO, messageReadDAO)
imEventHandler := imApp.ProvideIMEventHandler(imService, hub)
offlinePusher := imApp.ProvideOfflinePusher(imService, conversationDAO, pubSub)
imController := imApp.ProvideIMController(imService)
// File 模块初始化
fileService := service4.NewFileService(minioClient, minioConfig)
fileController := controller4.NewFileController(fileService)
// Group 模块初始化
joinRequestDAO := dao4.NewJoinRequestDAO(gormDB)
groupService := service5.NewGroupService(groupDAO, joinRequestDAO, friendshipDAO, pubSub, messageDAO, notifyService)
groupController := controller5.NewGroupController(groupService)
// Admin 群组管理初始化
groupManageService := service2.NewGroupManageService(gormDB, groupDAO)
groupManageController := controller2.NewGroupManageController(groupManageService)
// Admin 消息管理初始化
messageManageDAO := dao2.NewMessageManageDAO(gormDB)
conversationDAO := im.ProvideConversationDAO(gormDB)
messageManageService := service2.NewMessageManageService(messageManageDAO, userDAO, conversationDAO, pubSub)
messageManageController := controller2.NewMessageManageController(messageManageService)
app := NewApp(cfg, gormDB, client, minioClient, authService, authController, adminAuthController, userManageController, onlineController, contactManageController, groupManageController, messageManageController, handler, hub, pubSub, onlineService, contactController, imController, imEventHandler, offlinePusher, fileController, groupController, notifyService, notificationController, notifyCleanupTask)
handler := ws.ProvideWSHandler(hub, pubSub, jwtConfig, onlineService, authService)
friendGroupDAO := dao3.NewFriendGroupDAO(gormDB)
notificationDAO := dao5.NewNotificationDAO(gormDB)
notifyService := service3.NewNotifyService(notificationDAO, pubSub, friendshipDAO)
contactService := service4.NewContactService(friendshipDAO, friendGroupDAO, onlineService, notifyService)
contactController := controller3.NewContactController(contactService)
messageDAO := im.ProvideMessageDAO(gormDB)
messageReadDAO := dao4.NewMessageReadDAO(gormDB)
imService := im.ProvideIMService(conversationDAO, messageDAO, pubSub, client, friendshipDAO, friendshipDAO, groupDAO, messageReadDAO)
imController := im.ProvideIMController(imService)
eventHandler := im.ProvideIMEventHandler(imService, hub)
offlinePusher := im.ProvideOfflinePusher(imService, conversationDAO, pubSub)
fileService := service5.NewFileService(minioClient, minioConfig)
fileController := controller4.NewFileController(fileService)
joinRequestDAO := dao4.NewJoinRequestDAO(gormDB)
groupService := service6.NewGroupService(groupDAO, joinRequestDAO, friendshipDAO, pubSub, messageDAO, notifyService)
groupController := controller5.NewGroupController(groupService)
notificationController := controller6.NewNotificationController(notifyService)
cleanupTask := task.NewCleanupTask(notificationDAO)
meetingRoomDAO := dao6.NewMeetingRoomDAO(gormDB)
meetingParticipantDAO := dao6.NewMeetingParticipantDAO(gormDB)
meetingChatDAO := dao6.NewMeetingChatDAO(gormDB)
meetingService := service7.NewMeetingService(meetingRoomDAO, meetingParticipantDAO, meetingChatDAO, gormDB, client, pubSub, notifyService, friendshipDAO, onlineService)
meetingController := controller7.NewMeetingController(meetingService)
app := NewApp(cfg, gormDB, client, minioClient, authService, authController, adminAuthController, userManageController, onlineController, contactManageController, groupManageController, messageManageController, handler, hub, pubSub, onlineService, contactController, imController, eventHandler, offlinePusher, fileController, groupController, notifyService, notificationController, cleanupTask, meetingService, meetingController)
return app, nil
}