add like functionality with Like model, implement like/unlike methods, and update Post and Comment models to track like counts

This commit is contained in:
2025-07-22 22:45:55 +08:00
parent cbe73121f2
commit 562b9bd17f
15 changed files with 216 additions and 33 deletions

8
internal/dto/label.go Normal file
View File

@ -0,0 +1,8 @@
package dto
type LabelDto struct {
Key string `json:"key"`
Value string `json:"value"`
Color string `json:"color"`
TailwindClassName string `json:"tailwind_class_name"`
}

16
internal/dto/post.go Normal file
View File

@ -0,0 +1,16 @@
package dto
type PostDto struct {
UserID uint `json:"user_id"` // 发布者的用户ID
Title string `json:"title"` // 帖子标题
Content string `json:"content"`
Labels []LabelDto `json:"labels"` // 关联的标签
IsPrivate bool `json:"is_private"` // 是否为私密帖子
}
type CreatePostReq struct {
Title string `json:"title"`
Content string `json:"content"`
Labels []LabelDto `json:"labels"`
IsPrivate bool `json:"is_private"`
}