You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

package models
import "time"
4 years ago
const (
StatusDraft = 1
StatusPublished = 2
StatusHidden = 3
)
4 years ago
type Story struct {
4 years ago
ID string `json:"id"`
4 years ago
Type string `json:"type"`
4 years ago
Creator *UserSimple `json:"creator"`
4 years ago
CreatorID string `json:"creatorId"`
4 years ago
Title string `json:"title"`
Slug string `json:"slug"`
Md string `json:"md"`
URL string `json:"url"`
Cover string `json:"cover"`
Brief string `json:"brief"`
4 years ago
Tags []string `json:"tags"`
4 years ago
RawTags []*Tag `json:"rawTags"`
Likes int `json:"likes"`
Liked bool `json:"liked"`
Comments int `json:"comments"`
Views int `json:"views"`
Bookmarked bool `json:"bookmarked"`
Status int `json:"status"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
}
4 years ago
type Stories []*Story
4 years ago
func (s Stories) Len() int { return len(s) }
func (s Stories) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s Stories) Less(i, j int) bool {
return s[i].Created.Unix() > s[j].Created.Unix()
}
4 years ago
4 years ago
type FavorStories []*Story
4 years ago
4 years ago
func (s FavorStories) Len() int { return len(s) }
func (s FavorStories) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s FavorStories) Less(i, j int) bool {
return s[i].Likes > s[j].Likes
4 years ago
}