-
Notifications
You must be signed in to change notification settings - Fork 57
/
model.go
59 lines (51 loc) · 1.69 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package database
import (
"time"
)
// create database kim_base default character set utf8mb4 collate utf8mb4_unicode_ci;
// create database kim_message default character set utf8mb4 collate utf8mb4_unicode_ci;
type Model struct {
ID int64 `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
}
type MessageIndex struct {
ID int64 `gorm:"primarykey"`
AccountA string `gorm:"index;size:60;not null;comment:队列唯一标识"`
AccountB string `gorm:"size:60;not null;comment:另一方"`
Direction byte `gorm:"default:0;not null;comment:1表示AccountA为发送者"`
MessageID int64 `gorm:"not null;comment:关联消息内容表中的ID"`
Group string `gorm:"size:30;comment:群ID,单聊情况为空"`
SendTime int64 `gorm:"index;not null;comment:消息发送时间"`
}
type MessageContent struct {
ID int64 `gorm:"primarykey"`
Type byte `gorm:"default:0"`
Body string `gorm:"size:5000;not null"`
Extra string `gorm:"size:500"`
SendTime int64 `gorm:"index"`
}
type User struct {
Model
App string `gorm:"size:30"`
Account string `gorm:"uniqueIndex;size:60"`
Password string `gorm:"size:30"`
Avatar string `gorm:"size:200"`
Nickname string `gorm:"size:20"`
}
type Group struct {
Model
Group string `gorm:"uniqueIndex;size:30"`
App string `gorm:"size:30"`
Name string `gorm:"size:50"`
Owner string `gorm:"size:60"`
Avatar string `gorm:"size:200"`
Introduction string `gorm:"size:300"`
}
// GroupMember GroupMember
type GroupMember struct {
Model
Account string `gorm:"uniqueIndex:uni_gp_acc;size:60"`
Group string `gorm:"uniqueIndex:uni_gp_acc;index;size:30"`
Alias string `gorm:"size:30"`
}