feat: news router

This commit is contained in:
ericprd
2025-03-02 04:36:17 +08:00
parent f4ae93bc48
commit 915f12eaf7
49 changed files with 863 additions and 132 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
package categorydomain
type Category struct {
ID string `json:"id"`
ID string `json:"id" gorm:"primaryKey"`
Name string `json:"name"`
Code string `json:"code"`
}
-12
View File
@@ -1,12 +0,0 @@
package newsdomain
type News struct {
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"`
Slug string `json:"slug"`
Author string `json:"author"`
}
+32
View File
@@ -0,0 +1,32 @@
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 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 []categorydomain.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"`
}
+1 -1
View File
@@ -6,7 +6,7 @@ type TagReq struct {
}
type Tag struct {
ID string `json:"id"`
ID string `json:"id" gorm:"primaryKey"`
Code string `json:"code"`
Name string `json:"name"`
}