refactor: update GetAll method to return NewsResponse and rename clicked to views

This commit is contained in:
Ardeman
2025-03-24 15:24:52 +08:00
parent 09d9c4efb8
commit 49dc0e4a7b
7 changed files with 16 additions and 13 deletions
+7 -3
View File
@@ -27,19 +27,23 @@ type News struct {
Title string `json:"title"`
Content string `json:"content"`
FeaturedImage string `json:"featured_image"`
Tags []tagdomain.Tag `gorm:"many2many:news_tags" json:"tags"`
Categories []categorydomain.Category `gorm:"many2many:news_categories" json:"categories"`
Tags []tagdomain.Tag `gorm:"many2many:news_tags;foreignKey:ID;joinForeignKey:news_id;References:ID;joinReferences:tag_id" json:"tags"`
Categories []categorydomain.Category `gorm:"many2many:news_categories;foreignKey:ID;joinForeignKey:news_id;References:ID;joinReferences:category_id" json:"categories"`
IsPremium bool `json:"is_premium"`
Slug string `json:"slug"`
AuthorID string `json:"author_id"`
LiveAt time.Time `json:"live_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Clicked int64 `json:"clicked" gorm:"-"`
Author Staff `json:"author"`
}
type NewsResponse struct {
News
Views int64 `json:"views"`
}
type NewsUpdate struct {
ID string `json:"id"`
Title string `json:"title"`