Skip to content

Instantly share code, notes, and snippets.

@kanzitelli
Last active September 7, 2019 20:13
Show Gist options
  • Save kanzitelli/eab464eab905ff58e39978960240d3c8 to your computer and use it in GitHub Desktop.
Save kanzitelli/eab464eab905ff58e39978960240d3c8 to your computer and use it in GitHub Desktop.
Models. #1
package models
// News <model>
// is used to describe article model.
type News struct {
ID string `json:"_id" bson:"_id"`
Title string `json:"title" bson:"title"`
Preamble string `json:"preamble" bson:"preamble"`
TimeAdded int64 `json:"time_added" bson:"time_added"`
Link string `json:"link" bson:"link"`
NewsType NewsType `json:"news_type" bson:"news_type"`
NewsSource NewsSource `json:"news_source" bson:"news_source"`
}
package models
var (
SecretMagNewsSource = NewsSource{
ID: "f3fefa39-8adf-4e66-8f7c-18a071772a47",
Name: "Secret Mag",
ImageURL: "/images/secret_mag.png",
Types: []NewsType{TypeNews},
}
TheVillageNewsSource = NewsSource{
ID: "5c118e2b-1ed4-41af-bcb3-f5bbc11d55d3",
Name: "The Village",
ImageURL: "/images/the_village.png",
Types: []NewsType{TypeNews, TypeBusiness, TypeStyle},
}
TheoryAndPracticeNewsSource = NewsSource{
ID: "04e00787-598a-40bf-baf6-aa2ba1f8203c",
Name: "Theory and Practice",
ImageURL: "/images/theory_and_practice.png",
Types: []NewsType{TypePost},
}
)
// NewsSource <model>
// is used to describe news source model.
type NewsSource struct {
ID string `json:"_id" bson:"_id"`
Name string `json:"name" bson:"name"`
ImageURL string `json:"image_url" bson:"image_url"`
Types []NewsType `json:"types" bson:"types"`
}
package models
var (
TypeNews = NewsType{
ID: "6cef0d43-c49a-401a-9820-eda43a483a21",
Type: "news",
Name: "Новости",
}
TypePost = NewsType{
ID: "f98332cc-37a9-48c8-9abf-12b84de3d673",
Type: "post",
Name: "Пост",
}
TypeBusiness = NewsType{
ID: "ce0ef1ab-655b-475e-98b3-7c8fec74a3e8",
Type: "business",
Name: "Бизнес",
}
TypeStyle = NewsType{
ID: "0c05b2cf-77ce-484a-85b8-fd161500be1e",
Type: "style",
Name: "Стиль",
}
)
// NewsType <struct>
// is used to describe news type model.
type NewsType struct {
ID string `json:"_id" bson:"_id"`
Type string `json:"type" bson:"type"`
Name string `json:"name" bson:"name"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment