-
Notifications
You must be signed in to change notification settings - Fork 0
/
article.go
66 lines (62 loc) · 1.71 KB
/
article.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package mongo
import (
"github.com/adamdyszy/sportsnews/types"
"time"
)
/*
ArticleBson is a copy of Article but with bson tags
*/
type articleBson struct {
Published time.Time `bson:"published"`
TeamId string `bson:"teamId"`
NewsId string `bson:"newsId"`
Content string `bson:"content,omitempty"`
GalleryUrls string `bson:"galleryUrls,omitempty"`
Id string `bson:"id"`
ImageURL string `bson:"imageUrl,omitempty"`
OptaMatchID string `bson:"optaMatchId,omitempty"`
Teaser string `bson:"teaser,omitempty"`
Title string `bson:"title,omitempty"`
URL string `bson:"url,omitempty"`
VideoURL string `bson:"videoUrl,omitempty"`
Type []string `bson:"type,omitempty"`
HasDetails bool `bson:"hasDetails"`
}
func fromArticle(a types.Article) articleBson {
return articleBson{
TeamId: a.TeamId,
NewsId: a.NewsId,
Published: a.Published,
Content: a.Content,
GalleryUrls: a.GalleryUrls,
Id: string(a.Id),
ImageURL: a.ImageURL,
OptaMatchID: a.OptaMatchId,
Teaser: a.Teaser,
Title: a.Title,
Type: a.Type,
URL: a.URL,
VideoURL: a.VideoURL,
HasDetails: a.HasDetails,
}
}
func (a *articleBson) ToArticle() types.Article {
return types.Article{
ArticleKey: types.ArticleKey{
TeamId: a.TeamId,
NewsId: a.NewsId,
Published: a.Published,
},
Content: a.Content,
GalleryUrls: a.GalleryUrls,
Id: types.ArticleId(a.Id),
ImageURL: a.ImageURL,
OptaMatchId: a.OptaMatchID,
Teaser: a.Teaser,
Title: a.Title,
Type: a.Type,
URL: a.URL,
VideoURL: a.VideoURL,
HasDetails: a.HasDetails,
}
}