Files
nl-game-api/internal/model/social.go
2026-08-14 13:17:03 +08:00

34 lines
1.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
// 好友关系状态常量
const (
FriendStatusPending = 1 // 待验证(等待对方同意)
FriendStatusAccepted = 2 // 已通过(互为好友)
)
// Friend 好友关系表:申请方向为 user_id → friend_id通过后一条记录即代表双向好友
type Friend struct {
ID int `gorm:"primaryKey" json:"id"` // 关系ID
UserID int `gorm:"index" json:"user_id"` // 发起方用户ID申请人
FriendID int `gorm:"index" json:"friend_id"` // 接收方用户ID被申请人
Status int `gorm:"default:1" json:"status"` // 状态1待验证 2已通过
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"` // 申请时间int 时间戳)
UpdatedAt int64 `gorm:"autoUpdateTime" json:"updated_at"` // 状态更新时间int 时间戳)
}
// TableName 指定表名
func (Friend) TableName() string { return "friends" }
// ChatMessage 私聊消息表:仅好友之间可互发
type ChatMessage struct {
ID int `gorm:"primaryKey" json:"id"` // 消息ID
FromID int `gorm:"index" json:"from_id"` // 发送方用户ID
ToID int `gorm:"index" json:"to_id"` // 接收方用户ID
Content string `gorm:"size:500" json:"content"` // 消息内容(纯文本)
IsRead int `gorm:"default:0" json:"is_read"` // 接收方是否已读0未读 1已读
CreatedAt int64 `gorm:"autoCreateTime" json:"created_at"` // 发送时间int 时间戳)
}
// TableName 指定表名
func (ChatMessage) TableName() string { return "chat_messages" }