36 lines
1.7 KiB
Go
36 lines
1.7 KiB
Go
package database
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type News struct {
|
|
ID string `gorm:"primaryKey" json:"id"`
|
|
Title string `gorm:"default:null" json:"title"`
|
|
Tags []Tag `gorm:"many2many:news_tags" json:"tags"`
|
|
Categories []Category `gorm:"many2many:news_categories" json:"categories"`
|
|
Content string `gorm:"default:null" json:"content"`
|
|
LiveAt time.Time `gorm:"not null" json:"live_at"`
|
|
AuthorID string `gorm:"not null" json:"author_id"`
|
|
IsPremium bool `gorm:"default:false" json:"is_premium"`
|
|
Slug string `gorm:"default:null" json:"slug"`
|
|
FeaturedImage string `gorm:"default:null" json:"featured_image"`
|
|
CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
|
|
}
|
|
|
|
type NewsModel struct {
|
|
ID string `gorm:"primaryKey" json:"id"`
|
|
Title string `json:"title"`
|
|
Content string `json:"content"`
|
|
Categories []CategoryModel `gorm:"many2many:news_categories" json:"categories"`
|
|
Tags []TagModel `gorm:"many2many:news_tags" json:"tags"`
|
|
IsPremium bool `gorm:"default:false" json:"is_premium"`
|
|
Slug string `gorm:"default:null" json:"slug"`
|
|
FeaturedImage string `gorm:"default:null" json:"featured_image"`
|
|
AuthorID string `gorm:"not null" json:"author_id"`
|
|
LiveAt time.Time `gorm:"not null" json:"live_at"`
|
|
CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
|
|
}
|