Compare commits

..

No commits in common. "fe9d0650dcb6608f4379e3eba0f00f9c2efbae2c" and "c721978ceca514f9ad5c0fbead12238ce61b6ac8" have entirely different histories.

2 changed files with 2 additions and 3 deletions

View File

@ -57,7 +57,7 @@ func GetMsgUserByIndex(from_user_id, to_user_id, msg_type, index, status int) ([
res = DB.Debug().Where("from_user_id = ? and to_user_id = ? and type = ? and status = ? ", from_user_id, to_user_id, msg_type, status).Order("created_at DESC").Limit(20 * index).Find(&msgs) res = DB.Debug().Where("from_user_id = ? and to_user_id = ? and type = ? and status = ? ", from_user_id, to_user_id, msg_type, status).Order("created_at DESC").Limit(20 * index).Find(&msgs)
} else if msg_type == 1 { } else if msg_type == 1 {
//单聊,只有两个人的消息 //单聊,只有两个人的消息
res = DB.Debug().Raw("select * from messages where (from_user_id = ? AND to_user_id = ?) and type = ? or (from_user_id = ? AND to_user_id = ?) and type = ? order by created_at desc limit ?", from_user_id, to_user_id, msg_type, to_user_id, from_user_id, msg_type, 20*index).Scan(&msgs) res = DB.Debug().Raw("select * from messages where (from_user_id = ? AND to_user_id = ?) or (from_user_id = ? AND to_user_id = ?) and type = ? order by created_at desc limit ?", from_user_id, to_user_id, to_user_id, from_user_id, msg_type, 20*index).Scan(&msgs)
//res = DB.Debug().Where("(from_user_id = ? AND to_user_id = ?) or (from_user_id = ? AND to_user_id = ?) and type = ? ", from_user_id, to_user_id, to_user_id, from_user_id, msg_type).Order("created_at DESC").Limit(20 * index).Find(&msgs) //res = DB.Debug().Where("(from_user_id = ? AND to_user_id = ?) or (from_user_id = ? AND to_user_id = ?) and type = ? ", from_user_id, to_user_id, to_user_id, from_user_id, msg_type).Order("created_at DESC").Limit(20 * index).Find(&msgs)
} else { } else {
res = DB.Debug().Where("from_user_id = ? and to_user_id = ? and type = ? ", from_user_id, to_user_id, msg_type).Order("created_at DESC").Limit(20 * index).Find(&msgs) res = DB.Debug().Where("from_user_id = ? and to_user_id = ? and type = ? ", from_user_id, to_user_id, msg_type).Order("created_at DESC").Limit(20 * index).Find(&msgs)

View File

@ -362,8 +362,7 @@ func ServerSendMsg(c *gin.Context) {
if len(msgs) > 0 { if len(msgs) > 0 {
msg := msgs[0] msg := msgs[0]
//发送消息 //发送消息
msg_str, _ := json.Marshal(msg) _, err := c.Writer.Write([]byte("data: " + msg.Msg + "\n\n"))
_, err := c.Writer.Write([]byte("data: " + string(msg_str) + "\n\n"))
if err != nil { if err != nil {
worker.SetRedisWithExpire("user_"+strconv.Itoa(user_id)+"_status_v2", "0", time.Second*3600) worker.SetRedisWithExpire("user_"+strconv.Itoa(user_id)+"_status_v2", "0", time.Second*3600)
break break