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

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
+43 -4
View File
@@ -1,14 +1,53 @@
package models
import "time"
import (
"time"
)
type ChatMessage struct {
User Users
Time time.Time
Text string
UserID string
UserName string
CreateTx time.Time
Type string
Text string
}
const (
ChatTypeText = "TEXT" // 对话
ChatTypeCard = "CARD" // 工具卡片分享
)
func NewTextChatMsg(user *Users, text string) *ChatMessage {
return &ChatMessage{
UserID: user.ID,
UserName: user.Name,
CreateTx: time.Now(),
Type: ChatTypeText,
Text: text,
}
}
type Message struct {
Cmd string
User UserFollows
ChatMessage ChatMessage
}
//
//// Value 接口,Value 返回 json value any -> string
//func (j *Users) Value() (driver.Value, error) {
// return json.Marshal(j)
//}
//
//// Scan 接口,Scan 将 value 扫描至 Jsonb
//func (j *Users) Scan(value interface{}) error {
// bytes, ok := value.([]byte)
// if !ok {
// return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
// }
// err := json.Unmarshal(bytes, j)
// if err != nil {
// return err
// }
// return nil
//}