完善聊天功能 初步构建十子棋功能

This commit is contained in:
2024-10-15 21:13:17 +08:00
parent 245875881c
commit b3cf948fd2
15 changed files with 303 additions and 84 deletions
+21
View File
@@ -0,0 +1,21 @@
package repo
import (
"gorm.io/gorm"
"work_cation/models"
)
type chatMessageRepo struct{}
var ChatMsg = &chatMessageRepo{}
func (*chatMessageRepo) GetUserMsgs(db *gorm.DB, uuid string, limit int) []models.ChatMessage {
var msgs []models.ChatMessage
// ASC:升序(默认),DESC:降序。
db.Order("create_tx ASC").Limit(limit).Where("user_id = ?", uuid).Find(&msgs)
return msgs
}
func (*chatMessageRepo) Create(db *gorm.DB, msg *models.ChatMessage) error {
return db.Create(msg).Error
}