首次提交
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// Post 动态
|
||||
type Post struct {
|
||||
ID string `gorm:"primaryKey;type:varchar(32)" json:"id"`
|
||||
UserID string `gorm:"column:user_id;type:varchar(32);not null;index" json:"userId"`
|
||||
Content *string `gorm:"type:text" json:"content,omitempty"`
|
||||
Images *string `gorm:"type:text" json:"images,omitempty"`
|
||||
Privacy int `gorm:"default:1" json:"privacy"`
|
||||
Likes int `gorm:"default:0" json:"likes"`
|
||||
Comments int `gorm:"default:0" json:"comments"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
|
||||
User User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
||||
}
|
||||
|
||||
func (Post) TableName() string { return "posts" }
|
||||
|
||||
// Friend 好友关系
|
||||
type Friend struct {
|
||||
UserID string `gorm:"column:user_id;type:varchar(32);not null;primaryKey"`
|
||||
FriendID string `gorm:"column:friend_id;type:varchar(32);not null;primaryKey"`
|
||||
Status string `gorm:"default:pending;type:varchar(20)" json:"status"`
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
}
|
||||
|
||||
func (Friend) TableName() string { return "friends" }
|
||||
|
||||
// Group 打卡小组
|
||||
type Group struct {
|
||||
ID string `gorm:"primaryKey;type:varchar(32)" json:"id"`
|
||||
Name string `gorm:"type:varchar(20);not null" json:"name"`
|
||||
Cover *string `gorm:"type:varchar(255)" json:"cover,omitempty"`
|
||||
Intro *string `gorm:"type:varchar(200)" json:"intro,omitempty"`
|
||||
Type string `gorm:"default:public;type:varchar(20)" json:"type"`
|
||||
MaxMember int `gorm:"column:max_member;default:50" json:"maxMember"`
|
||||
CreatedBy string `gorm:"column:created_by;type:varchar(32)" json:"createdBy"`
|
||||
CreatedAt time.Time `gorm:"column:created_at"`
|
||||
|
||||
Members []GroupMember `gorm:"foreignKey:GroupID" json:"-"`
|
||||
}
|
||||
|
||||
func (Group) TableName() string { return "groups" }
|
||||
|
||||
// GroupMember 小组成员
|
||||
type GroupMember struct {
|
||||
GroupID string `gorm:"column:group_id;type:varchar(32);not null;primaryKey"`
|
||||
UserID string `gorm:"column:user_id;type:varchar(32);not null;primaryKey"`
|
||||
Role string `gorm:"default:member;type:varchar(20)" json:"role"`
|
||||
JoinedAt time.Time `gorm:"column:joined_at"`
|
||||
|
||||
Group Group `gorm:"foreignKey:GroupID" json:"-"`
|
||||
}
|
||||
|
||||
func (GroupMember) TableName() string { return "group_members" }
|
||||
Reference in New Issue
Block a user