mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-10 08:32:26 +08:00
refactor: eiblog
This commit is contained in:
19
pkg/model/account.go
Normal file
19
pkg/model/account.go
Normal file
@@ -0,0 +1,19 @@
|
||||
// Package model provides ...
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Account 博客账户
|
||||
type Account struct {
|
||||
Username string `gorm:"primaryKey"` // 用户名
|
||||
Password string `gorm:"not null"` // 密码
|
||||
Email string `gorm:"not null"` // 邮件地址
|
||||
PhoneN string `gorm:"not null"` // 手机号
|
||||
Address string `gorm:"not null"` // 地址信息
|
||||
|
||||
LogoutTime time.Time `gorm:"default:null"` // 登出时间
|
||||
LoginIP string `gorm:"default:null"` // 最近登录IP
|
||||
LoginUA string `gorm:"default:null"` // 最近登录IP
|
||||
LoginTime time.Time `gorm:"default:now()"` // 最近登录时间
|
||||
CreateTime time.Time `gorm:"default:now()"` // 创建时间
|
||||
}
|
||||
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] }
|
||||
40
pkg/model/article.go
Normal file
40
pkg/model/article.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// Package model provides ...
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Article 文章
|
||||
type Article struct {
|
||||
ID int32 `gorm:"primaryKey;autoIncrement"` // 自增ID
|
||||
Author string `gorm:"not null"` // 作者名
|
||||
Slug string `gorm:"not null;uniqueIndex"` // 文章缩略名
|
||||
Title string `gorm:"not null"` // 标题
|
||||
Count int `gorm:"not null"` // 评论数量
|
||||
Content string `gorm:"not null"` // markdown内容
|
||||
SerieID int32 `gorm:"not null"` // 专题ID
|
||||
Tags string `gorm:"not null"` // tag,以逗号隔开
|
||||
IsDraft bool `gorm:"not null"` // 是否是草稿
|
||||
|
||||
DeleteTime time.Time `gorm:"default:null"` // 删除时间
|
||||
UpdateTime time.Time `gorm:"default:now()"` // 更新时间
|
||||
CreateTime time.Time `gorm:"default:now()"` // 创建时间
|
||||
|
||||
Header string `gorm:"-" bson:"-"` // header
|
||||
Excerpt string `gorm:"-" bson:"-"` // 预览信息
|
||||
Desc string `gorm:"-" bson:"-"` // 描述
|
||||
Thread string `gorm:"-" bson:"-"` // disqus thread
|
||||
Prev *Article `gorm:"-" bson:"-"` // 上篇文章
|
||||
Next *Article `gorm:"-" bson:"-"` // 下篇文章
|
||||
}
|
||||
|
||||
// SortedArticles 按时间排序后文章
|
||||
type SortedArticles []*Article
|
||||
|
||||
// Len 长度
|
||||
func (s SortedArticles) Len() int { return len(s) }
|
||||
|
||||
// Less 对比
|
||||
func (s SortedArticles) Less(i, j int) bool { return s[i].CreateTime.After(s[j].CreateTime) }
|
||||
|
||||
// Swap 交换
|
||||
func (s SortedArticles) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
14
pkg/model/blogger.go
Normal file
14
pkg/model/blogger.go
Normal file
@@ -0,0 +1,14 @@
|
||||
// Package model provides ...
|
||||
package model
|
||||
|
||||
// Blogger 博客信息
|
||||
type Blogger struct {
|
||||
BlogName string `gorm:"not null"` // 博客名
|
||||
SubTitle string `gorm:"not null"` // 子标题
|
||||
BeiAn string `gorm:"not null"` // 备案号
|
||||
BTitle string `gorm:"not null"` // 底部title
|
||||
Copyright string `gorm:"not null"` // 版权声明
|
||||
|
||||
SeriesSay string `gorm:"not null"` // 专题说明
|
||||
ArchivesSay string `gorm:"not null"` // 归档说明
|
||||
}
|
||||
27
pkg/model/series.go
Normal file
27
pkg/model/series.go
Normal file
@@ -0,0 +1,27 @@
|
||||
// Package model provides ...
|
||||
package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Series 专题
|
||||
type Series struct {
|
||||
ID int32 `gorm:"primaryKey;autoIncrement"` // 自增ID
|
||||
Slug string `gorm:"not null;uniqueIndex"` // 缩略名
|
||||
Name string `gorm:"not null"` // 专题名
|
||||
Desc string `gorm:"not null"` // 专题描述
|
||||
CreateTime time.Time `gorm:"default:now()"` // 创建时间
|
||||
|
||||
Articles SortedArticles `gorm:"-" bson:"-"` // 专题下的文章
|
||||
}
|
||||
|
||||
// SortedSeries 排序后专题
|
||||
type SortedSeries []*Series
|
||||
|
||||
// Len 长度
|
||||
func (s SortedSeries) Len() int { return len(s) }
|
||||
|
||||
// Less 比较
|
||||
func (s SortedSeries) Less(i, j int) bool { return s[i].ID > s[j].ID }
|
||||
|
||||
// Swap 交换
|
||||
func (s SortedSeries) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
Reference in New Issue
Block a user