package model import ( "gorm.io/gorm" ) const ( VisibilityPublic = iota VisibilityFensOnly VisibilitySelfOnly ) // 动态表 type Moment struct { gorm.Model UserID string `gorm:"column:user_id;type:varchar(32);not null;index:idx_user_id;comment:'发布者用户ID'"` Content string `gorm:"column:content;type:text;comment:'动态内容'"` Visibility uint8 `gorm:"column:visibility;type:tinyint unsigned;default:1;comment:'可见性;1:公开,2:仅好友可见,3:仅自己可见'"` Location string `gorm:"column:location;type:varchar(200);default:'';comment:'发布地点'"` Status uint8 `gorm:"column:status;type:tinyint unsigned;default:1;comment:'状态;0:删除,1:正常'"` LikeCount uint32 `gorm:"column:like_count;type:int unsigned;default:0;comment:'点赞数'"` CollectCount uint32 `gorm:"column:collect_count;type:int unsigned;default:0;comment:'收藏数'"` CommentCount uint32 `gorm:"column:comment_count;type:int unsigned;default:0;comment:'评论数'"` } // 动态文件表 type MomentFile struct { gorm.Model MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;comment:'动态ID'"` FileURL string `gorm:"column:file_url;type:varchar(255);not null;comment:'文件URL'"` FileType string `gorm:"column:file_type;type:varchar(15);not null;comment:'文件类型'"` SortOrder int `gorm:"column:sort_order;type:int;default:0;comment:'文件排序'"` } // 动态点赞表 type MomentLike struct { gorm.Model MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;comment:'动态ID'"` UserID string `gorm:"column:user_id;type:varchar(32);not null;comment:'点赞用户ID'"` } // 动态评论表 type MomentComment struct { gorm.Model MomentID uint `gorm:"column:moment_id;type:int unsigned;not null;comment:'动态ID'"` UserID string `gorm:"column:user_id;type:varchar(32);not null;comment:'评论用户ID'"` Content string `gorm:"column:content;type:text;not null;comment:'评论内容'"` ParentID uint `gorm:"column:parent_id;type:int unsigned;index:idx_parent_id;comment:'父评论ID,用于回复功能'"` } type MomentCollect struct { gorm.Model UserID string `gorm:"column:user_id;type:varchar(32);not null;comment:'收藏用户ID(关联we_media_user.user_id)'"` MomentID uint `gorm:"column:moment_id;type:bigint unsigned;not null;comment:'动态ID'"` } type CommentFile struct { gorm.Model CommentID uint `gorm:"column:comment_id;type:int unsigned;not null;comment:'评论ID'"` FileURL string `gorm:"column:file_url;type:varchar(255);not null;comment:'文件URL'"` FileType string `gorm:"column:file_type;type:varchar(15);not null;comment:'文件类型'"` SortOrder int `gorm:"column:sort_order;type:int;default:0;comment:'文件排序'"` } func (Moment) TableName() string { return "moment" } func (MomentFile) TableName() string { return "moment_file" } func (MomentLike) TableName() string { return "moment_like" } func (MomentComment) TableName() string { return "moment_comment" } func (MomentCollect) TableName() string { return "moment_collect" } func (CommentFile) TableName() string { return "moment_comment_file" }