2022-01-21 00:26:59 +00:00
|
|
|
package databag
|
|
|
|
|
|
|
|
import (
|
|
|
|
"databag/internal/store"
|
|
|
|
)
|
|
|
|
|
|
|
|
func getCardModel(card *store.Card) *Card {
|
|
|
|
|
|
|
|
// populate group id list
|
|
|
|
var groups []string;
|
|
|
|
for _, group := range card.Groups {
|
|
|
|
groups = append(groups, group.GroupId)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Card{
|
|
|
|
CardId: card.CardId,
|
2022-01-28 21:39:31 +00:00
|
|
|
NotifiedProfile: card.NotifiedProfile,
|
|
|
|
NotifiedContent: card.NotifiedContent,
|
|
|
|
NotifiedView: card.NotifiedView,
|
2022-01-21 00:26:59 +00:00
|
|
|
CardProfile: &CardProfile{
|
|
|
|
Guid: card.Guid,
|
|
|
|
Handle: card.Username,
|
|
|
|
Name: card.Name,
|
|
|
|
Description: card.Description,
|
|
|
|
Location: card.Location,
|
|
|
|
Revision: card.ProfileRevision,
|
|
|
|
ImageSet: card.Image != "",
|
|
|
|
Version: card.Version,
|
|
|
|
Node: card.Node,
|
|
|
|
},
|
|
|
|
CardData: &CardData {
|
|
|
|
Revision: card.DataRevision,
|
|
|
|
Status: card.Status,
|
|
|
|
Notes: card.Notes,
|
2022-01-21 23:08:52 +00:00
|
|
|
Token: card.OutToken,
|
2022-01-21 00:26:59 +00:00
|
|
|
Groups: groups,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-25 05:22:33 +00:00
|
|
|
func getGroupModel(group *store.Group) *Group {
|
|
|
|
return &Group{
|
|
|
|
GroupId: group.GroupId,
|
|
|
|
Revision: group.Revision,
|
|
|
|
DataType: group.DataType,
|
|
|
|
Data: group.Data,
|
|
|
|
Created: group.Created,
|
|
|
|
Updated: group.Updated,
|
|
|
|
}
|
|
|
|
}
|
2022-01-28 07:01:17 +00:00
|
|
|
|
|
|
|
func getArticleModel(article *store.Article, tagCount int32) *Article {
|
|
|
|
|
|
|
|
// populate group id list
|
|
|
|
var groups []string;
|
|
|
|
for _, group := range article.Groups {
|
|
|
|
groups = append(groups, group.GroupId)
|
|
|
|
}
|
|
|
|
|
|
|
|
// populate label id list
|
|
|
|
var labels []string;
|
|
|
|
for _, label := range article.Labels {
|
|
|
|
labels = append(labels, label.LabelId)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Article{
|
|
|
|
ArticleId: article.ArticleId,
|
2022-01-29 06:50:13 +00:00
|
|
|
ArticleBlockId: article.ArticleBlock.ArticleBlockId,
|
2022-01-28 07:01:17 +00:00
|
|
|
Revision: article.Revision,
|
|
|
|
DataType: article.DataType,
|
|
|
|
Data: article.Data,
|
|
|
|
Created: article.Created,
|
|
|
|
Updated: article.Updated,
|
|
|
|
Status: article.Status,
|
|
|
|
Labels: labels,
|
|
|
|
Groups: groups,
|
|
|
|
TagCount: tagCount,
|
|
|
|
TagUpdated: article.TagUpdated,
|
|
|
|
TagRevision: article.TagRevision,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|