24 lines
627 B
Go
24 lines
627 B
Go
|
|
package entity
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/gocql/gocql"
|
||
|
|
"github.com/google/uuid"
|
||
|
|
)
|
||
|
|
|
||
|
|
// Message 對應 Cassandra 的 messages_by_room 表
|
||
|
|
// Primary Key: (room_id, bucket_day)
|
||
|
|
// Clustering Key: ts DESC
|
||
|
|
type Message struct {
|
||
|
|
RoomID gocql.UUID `db:"room_id" partition_key:"true"`
|
||
|
|
BucketDay string `db:"bucket_day" partition_key:"true"` // yyyyMMdd
|
||
|
|
TS int64 `db:"ts" clustering_key:"true"` // timestamp
|
||
|
|
UID string `db:"uid"`
|
||
|
|
Content string `db:"content"`
|
||
|
|
MsgID uuid.UUID `db:"msg_id"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// TableName 返回表名
|
||
|
|
func (m Message) TableName() string {
|
||
|
|
return "messages_by_room"
|
||
|
|
}
|