mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-14 10:22:26 +08:00
refactor: eiblog
This commit is contained in:
23
pkg/model/archive.go
Normal file
23
pkg/model/archive.go
Normal file
@@ -0,0 +1,23 @@
|
||||
// Package model provides ...
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Archive 归档
|
||||
type Archive struct {
|
||||
Time time.Time
|
||||
|
||||
Articles SortedArticles `gorm:"-" bson:"-"` // 归档下的文章
|
||||
}
|
||||
|
||||
// SortedArchives 排序后的归档
|
||||
type SortedArchives []*Archive
|
||||
|
||||
// Len 长度
|
||||
func (s SortedArchives) Len() int { return len(s) }
|
||||
|
||||
// Less 比较
|
||||
func (s SortedArchives) Less(i, j int) bool { return s[i].Time.After(s[j].Time) }
|
||||
|
||||
// Swap 交换
|
||||
func (s SortedArchives) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
Reference in New Issue
Block a user