feat: 添加微语功能
- 新增微语页面,类似 Twitter/QQ 空间的短内容发布平台 - 添加 GitHub 风格热力图组件展示发布活动 - 支持发布微语、图片上传、标签、Emoji - 支持点赞、评论功能 - 右侧栏显示统计数据和热门标签 - 支持按标签筛选微语 - 后端新增微语相关 API(CRUD、点赞、评论、标签) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -62,3 +62,41 @@ type PostMeta struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// Micro 微语模型
|
||||
type Micro struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
UserID uint `json:"user_id" gorm:"index;not null"`
|
||||
Content string `json:"content" gorm:"type:text;not null"`
|
||||
Images string `json:"images" gorm:"type:text"` // JSON array of image URLs
|
||||
Tags string `json:"tags" gorm:"type:text"` // JSON array of tags
|
||||
LikeCount int `json:"like_count" gorm:"default:0"`
|
||||
CommentCount int `json:"comment_count" gorm:"default:0"`
|
||||
User User `json:"user" gorm:"foreignKey:UserID"`
|
||||
}
|
||||
|
||||
// MicroLike 微语点赞模型
|
||||
type MicroLike struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
MicroID uint `json:"micro_id" gorm:"uniqueIndex:idx_micro_user;not null"`
|
||||
UserID *uint `json:"user_id" gorm:"uniqueIndex:idx_micro_user;index"`
|
||||
IPHash string `json:"-" gorm:"uniqueIndex:idx_micro_ip;size:64"`
|
||||
}
|
||||
|
||||
// MicroComment 微语评论模型
|
||||
type MicroComment struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
MicroID uint `json:"micro_id" gorm:"index;not null"`
|
||||
UserID uint `json:"user_id" gorm:"index;not null"`
|
||||
ParentID *uint `json:"parent_id" gorm:"index"`
|
||||
Content string `json:"content" gorm:"type:text;not null"`
|
||||
User User `json:"user" gorm:"foreignKey:UserID"`
|
||||
Replies []MicroComment `json:"replies,omitempty" gorm:"foreignKey:ParentID"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user