修复了一些问题
This commit is contained in:
@@ -106,6 +106,8 @@ func initDB() *gorm.DB {
|
||||
&model.MomentLike{},
|
||||
&model.MomentComment{},
|
||||
&model.MomentNotification{},
|
||||
&model.MessageReadReceipt{},
|
||||
&model.UserSetting{},
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatalf("❌ 数据库迁移失败: %v", err)
|
||||
@@ -131,6 +133,8 @@ func initDB() *gorm.DB {
|
||||
{"moment_likes", "动态点赞表"},
|
||||
{"moment_comments", "动态评论表"},
|
||||
{"moment_notifications", "朋友圈通知表"},
|
||||
{"message_read_receipts", "消息已读回执表"},
|
||||
{"user_settings", "用户个性化设置表"},
|
||||
}
|
||||
|
||||
for _, tc := range tableComments {
|
||||
@@ -197,6 +201,15 @@ func main() {
|
||||
db := initDB() // 连接MySQL数据库
|
||||
rdb := initRedis() // 连接Redis
|
||||
|
||||
// 初始化 ip2region 离线 IP 库
|
||||
ip2regionPath := viper.GetString("ip2region.db_path")
|
||||
if ip2regionPath == "" {
|
||||
ip2regionPath = "./ip2region.xdb"
|
||||
}
|
||||
if err := utils.InitIP2Region(ip2regionPath); err != nil {
|
||||
log.Printf("⚠️ ip2region 初始化失败: %v", err)
|
||||
}
|
||||
|
||||
// 步骤2: 启动WebSocket工作池,用于处理WebSocket消息
|
||||
ws.StartWorkerPool()
|
||||
defer ws.StopWorkerPool() // 程序退出时关闭工作池
|
||||
@@ -283,7 +296,7 @@ func main() {
|
||||
clientID := fmt.Sprintf("%s-%d", viper.GetString("app.node_id"), time.Now().UnixNano())
|
||||
|
||||
// 步骤5: 创建客户端对象,包含连接和发送队列
|
||||
client := &manager.Client{ID: clientID, Conn: conn, SendQueue: make(chan []byte, 256)}
|
||||
client := &manager.Client{ID: clientID, RemoteIP: c.ClientIP(), Conn: conn, SendQueue: make(chan []byte, 256)}
|
||||
|
||||
// 步骤6: 注册客户端到管理器
|
||||
manager.Manager.Register(client)
|
||||
@@ -344,6 +357,7 @@ func main() {
|
||||
// 用户管理
|
||||
authGroup.GET("/user/my-info", api.GetMyInfoHandler)
|
||||
authGroup.GET("/user/list", api.GetUserListHandler)
|
||||
authGroup.GET("/user/:id", api.GetUserByIDHandler)
|
||||
authGroup.POST("/user/create", api.CreateUserHandler)
|
||||
authGroup.POST("/user/update", api.UpdateUserHandler)
|
||||
authGroup.POST("/user/delete", api.DeleteUserHandler)
|
||||
@@ -363,6 +377,15 @@ func main() {
|
||||
authGroup.POST("/contacts/update/:id", api.UpdateContactHandler)
|
||||
authGroup.POST("/contacts/delete/:id", api.DeleteContactHandler)
|
||||
|
||||
// 消息撤回、登出、已读回执
|
||||
authGroup.POST("/messages/recall", api.RecallMessageHandler)
|
||||
authGroup.POST("/messages/read-receipts", api.MarkMessagesReadHandler)
|
||||
authGroup.POST("/logout", api.LogoutHandler)
|
||||
|
||||
// 用户设置
|
||||
authGroup.GET("/user/settings", api.GetUserSettingsHandler)
|
||||
authGroup.POST("/user/settings", api.UpdateUserSettingsHandler)
|
||||
|
||||
// 会话管理
|
||||
authGroup.GET("/conversations/by-room/:room_id", api.GetConversationByRoomHandler)
|
||||
authGroup.GET("/conversations", api.GetConversationListHandler)
|
||||
@@ -389,7 +412,10 @@ func main() {
|
||||
authGroup.POST("/groups/:room_id/announcement", api.UpdateGroupAnnouncementHandler)
|
||||
authGroup.POST("/groups/:room_id/members/:user_id/mute", api.MuteGroupMemberHandler)
|
||||
authGroup.GET("/groups/:room_id/members/:user_id/mute", api.GetMemberMuteStatusHandler)
|
||||
authGroup.GET("/groups/:room_id/settings", api.GetGroupSettingsHandler)
|
||||
authGroup.POST("/groups/:room_id/settings", api.UpdateGroupSettingsHandler)
|
||||
authGroup.GET("/group-notifications", api.GetGroupNotificationsHandler)
|
||||
authGroup.GET("/calls/history", api.GetCallHistoryHandler)
|
||||
|
||||
// 附件管理
|
||||
authGroup.POST("/attachments/upload", api.UploadAttachmentHandler)
|
||||
|
||||
Reference in New Issue
Block a user