fix: create and get news
This commit is contained in:
@@ -3,7 +3,7 @@ package categorydomain
|
||||
import "time"
|
||||
|
||||
type Category struct {
|
||||
ID string `json:"id"`
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package newsdomain
|
||||
|
||||
import (
|
||||
"legalgo-BE-go/database"
|
||||
categorydomain "legalgo-BE-go/internal/domain/category"
|
||||
tagdomain "legalgo-BE-go/internal/domain/tag"
|
||||
"time"
|
||||
)
|
||||
@@ -17,16 +17,16 @@ type NewsReq struct {
|
||||
}
|
||||
|
||||
type News struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Content string `json:"content"`
|
||||
FeaturedImage string `json:"featured_image"`
|
||||
Tags []tagdomain.Tag `json:"tags"`
|
||||
Categories []database.Category `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"`
|
||||
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" json:"tags"`
|
||||
Categories []categorydomain.Category `gorm:"many2many:news_categories" 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"`
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
package tagdomain
|
||||
|
||||
import "time"
|
||||
|
||||
type TagReq struct {
|
||||
Code string `json:"code" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user