mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 14:04:08 +01:00
feat: add knowledgeHub domain
This commit is contained in:
parent
da4ab50e85
commit
0d2b38110a
58
backend/internal/domain/knowledgeHub.go
Normal file
58
backend/internal/domain/knowledgeHub.go
Normal file
@ -0,0 +1,58 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
validation "github.com/go-ozzo/ozzo-validation/v4"
|
||||
)
|
||||
|
||||
type KnowledgeArticle struct {
|
||||
UUID string
|
||||
Title string
|
||||
Content string
|
||||
Author string
|
||||
PublishDate time.Time
|
||||
ReadTime string
|
||||
Categories []string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
func (k *KnowledgeArticle) Validate() error {
|
||||
return validation.ValidateStruct(k,
|
||||
validation.Field(&k.Title, validation.Required),
|
||||
validation.Field(&k.Content, validation.Required),
|
||||
validation.Field(&k.Author, validation.Required),
|
||||
validation.Field(&k.PublishDate, validation.Required),
|
||||
)
|
||||
}
|
||||
|
||||
type TableOfContent struct {
|
||||
UUID string
|
||||
ArticleID string
|
||||
Title string
|
||||
Order int
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type RelatedArticle struct {
|
||||
UUID string
|
||||
ArticleID string
|
||||
RelatedTitle string
|
||||
RelatedTag string
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
}
|
||||
|
||||
type KnowledgeHubRepository interface {
|
||||
GetArticleByID(context.Context, string) (KnowledgeArticle, error)
|
||||
GetArticlesByCategory(ctx context.Context, category string) ([]KnowledgeArticle, error)
|
||||
GetAllArticles(ctx context.Context) ([]KnowledgeArticle, error)
|
||||
CreateOrUpdateArticle(context.Context, *KnowledgeArticle) error
|
||||
DeleteArticle(context.Context, string) error
|
||||
|
||||
GetTableOfContents(ctx context.Context, articleID string) ([]TableOfContent, error)
|
||||
GetRelatedArticles(ctx context.Context, articleID string) ([]RelatedArticle, error)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user