refactor: update GetAll method to return NewsResponse and rename clicked to views
This commit is contained in:
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user