This commit is contained in:
2025-12-08 09:08:10 +08:00
parent 976b6dec2d
commit 380eae3da5
5 changed files with 1563 additions and 0 deletions

View File

@@ -101,6 +101,10 @@ func initDB() *gorm.DB {
&model.Attachment{},
&model.ApiRequestLog{},
&model.LoginLog{},
&model.Moment{},
&model.MomentLike{},
&model.MomentComment{},
&model.MomentNotification{},
)
if err != nil {
log.Fatalf("❌ 数据库迁移失败: %v", err)
@@ -122,6 +126,10 @@ func initDB() *gorm.DB {
{"attachments", "附件表,记录上传的文件信息"},
{"api_request_logs", "接口请求日志表"},
{"login_logs", "登录日志表"},
{"moments", "朋友圈动态表"},
{"moment_likes", "动态点赞表"},
{"moment_comments", "动态评论表"},
{"moment_notifications", "朋友圈通知表"},
}
for _, tc := range tableComments {
@@ -215,6 +223,7 @@ func main() {
service.InitRoomService(db) // 房间服务(聊天房间管理)
service.InitAttachmentService(db) // 附件服务(文件上传、管理)
service.InitLoginLogService(db) // 登录日志服务(记录登录历史)
service.InitMomentService(db) // 朋友圈服务(动态、点赞、评论)
// 步骤5: 启动TURN服务器(用于WebRTC音视频通话)
go turnserver.Start()
@@ -373,6 +382,9 @@ func main() {
authGroup.GET("/attachments", api.GetAttachmentsHandler)
authGroup.GET("/attachments/:id", api.GetAttachmentHandler)
authGroup.POST("/attachments/delete/:id", api.DeleteAttachmentHandler)
// 朋友圈管理
api.RegisterMomentRoutes(authGroup)
}
}