68 lines
2.2 KiB
Go
Raw Normal View History

2025-03-02 04:36:17 +08:00
package newsdomain
import (
2025-03-05 22:15:39 +08:00
categorydomain "legalgo-BE-go/internal/domain/category"
2025-03-02 04:36:17 +08:00
tagdomain "legalgo-BE-go/internal/domain/tag"
"time"
)
type NewsReq struct {
Title string `json:"title" validate:"required"`
Content string `json:"content"`
FeaturedImage string `json:"featured_image"`
Tags []string `json:"tags"`
Categories []string `json:"categories"`
IsPremium bool `json:"is_premium"`
LiveAt string `json:"live_at" validate:"required"`
}
type Staff struct {
ID string `json:"id"`
Name string `json:"name"`
ProfilePicture string `json:"profile_picture"`
}
2025-03-02 04:36:17 +08:00
type News struct {
2025-03-05 22:15:39 +08:00
ID string `json:"id" gorm:"primaryKey"`
Title string `json:"title"`
Content string `json:"content"`
FeaturedImage string `json:"featured_image"`
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"`
2025-03-05 22:15:39 +08:00
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"`
Author Staff `json:"author"`
2025-03-02 04:36:17 +08:00
}
2025-03-06 23:55:46 +08:00
type NewsResponse struct {
News
Views int64 `json:"views"`
}
2025-03-06 23:55:46 +08:00
type NewsUpdate struct {
ID string `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
FeaturedImage string `json:"featured_image"`
Tags []string `json:"tags"`
Categories []string `json:"categories"`
IsPremium bool `json:"is_premium"`
LiveAt time.Time `json:"live_at"`
}
2025-03-20 13:13:28 +08:00
type Filter struct {
2025-03-24 18:11:08 +08:00
Category, Tags, Active, Search string
2025-03-20 13:13:28 +08:00
}
type NewsFilter struct {
Tags []string
2025-03-07 14:30:31 +08:00
Category []string
2025-03-20 13:13:28 +08:00
Active string
2025-03-24 18:11:08 +08:00
Search string
}