mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
41 lines
902 B
Go
41 lines
902 B
Go
package internal
|
|
|
|
import (
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
)
|
|
|
|
type Article struct {
|
|
IdName string `json:"id_name" bson:"id_name"`
|
|
Date int64 `json:"date" bson:"date"`
|
|
Content interface{} `json:"content" bson:"content"`
|
|
}
|
|
|
|
type DelArticle struct {
|
|
IdName string `json:"id_name" bson:"id_name"`
|
|
}
|
|
|
|
var articlesLocation = Location{Database: "gohcms", Collection: "articles"}
|
|
|
|
func GetAllArticlesBusiness(documents [][]byte) []Article {
|
|
var articles = []Article{}
|
|
|
|
for i := 0; i < len(documents); i++ {
|
|
var newArticle Article
|
|
bson.Unmarshal(documents[i], &newArticle)
|
|
articles = append(articles, newArticle)
|
|
}
|
|
|
|
return articles
|
|
}
|
|
|
|
func IsArticleIdAlreadyUsed(id string, documents [][]byte) bool {
|
|
for i := 0; i < len(documents); i++ {
|
|
var newArticle Article
|
|
bson.Unmarshal(documents[i], &newArticle)
|
|
if newArticle.IdName == id {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|