* 'main' of https://github.com/ardeman/project-legalgo-go: fix: search news title by query
68 lines
2.2 KiB
Go
68 lines
2.2 KiB
Go
package newsdomain
|
|
|
|
import (
|
|
categorydomain "legalgo-BE-go/internal/domain/category"
|
|
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"`
|
|
}
|
|
|
|
type News struct {
|
|
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"`
|
|
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"`
|
|
}
|
|
|
|
type NewsResponse struct {
|
|
News
|
|
Views int64 `json:"views"`
|
|
}
|
|
|
|
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"`
|
|
}
|
|
|
|
type Filter struct {
|
|
Category, Tags, Active, Search string
|
|
}
|
|
|
|
type NewsFilter struct {
|
|
Tags []string
|
|
Category []string
|
|
Active string
|
|
Search string
|
|
}
|