chore: rename field name

This commit is contained in:
deepzz0
2021-04-27 16:16:32 +08:00
parent 1815cea2cd
commit 6b74e1d208
17 changed files with 586 additions and 454 deletions

View File

@@ -3,17 +3,19 @@ package model
import "time"
// use snake_case as column name
// 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"` // 地址信息
Username string `gorm:"column:username;primaryKey" bson:"username"` // 用户名
Password string `gorm:"column:password;not null" bson:"password"` // 密码
Email string `gorm:"column:email;not null" bson:"email"` // 邮件地址
PhoneN string `gorm:"column:phone_n;not null" bson:"phone_n"` // 手机号
Address string `gorm:"column:address;not null" bson:"address"` // 地址信息
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()"` // 创建时间
LogoutAt time.Time `gorm:"column:logout_at;default:null" bson:"logout_at"` // 登出时间
LoginIP string `gorm:"column:login_ip;default:null" bson:"login_ip"` // 最近登录IP
LoginUA string `gorm:"column:login_ua;default:null" bson:"login_ua"` // 最近登录IP
LoginAt time.Time `gorm:"column:login_at;default:now()" bson:"login_at"` // 最近登录时间
CreatedAt time.Time `gorm:"column:creatd_at;default:now()" bson:"created_at"` // 创建时间
}

View File

@@ -3,9 +3,11 @@ package model
import "time"
// use snake_case as column name
// Archive 归档
type Archive struct {
Time time.Time
Time time.Time `gorm:"column:time;not null" bson:"time"`
Articles SortedArticles `gorm:"-" bson:"-"` // 归档下的文章
}

View File

@@ -3,21 +3,23 @@ package model
import "time"
// use snake_case as column name
// Article 文章
type Article struct {
ID int `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 int `gorm:"not null"` // 专题ID
Tags string `gorm:"not null"` // tag,以逗号隔开
IsDraft bool `gorm:"not null"` // 是否是草稿
ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID
Author string `gorm:"column:author;not null" bson:"author"` // 作者名
Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 文章缩略名
Title string `gorm:"column:title;not null" bson:"title"` // 标题
Count int `gorm:"column:count;not null" bson:"count"` // 评论数量
Content string `gorm:"column:content;not null" bson:"content"` // markdown内容
SeriesID int `gorm:"column:series_id;not null" bson:"series_id"` // 专题ID
Tags string `gorm:"column:tags;not null" bson:"tags"` // tag,以逗号隔开
IsDraft bool `gorm:"column:is_draft;not null" bson:"is_draft"` // 是否是草稿
DeleteTime time.Time `gorm:"default:null"` // 删除时间
UpdateTime time.Time `gorm:"default:now()"` // 更新时间
CreateTime time.Time `gorm:"default:now()"` // 创建时间
DeletedAt time.Time `gorm:"column:deleted_at;default:null" bson:"deleted_at"` // 删除时间
UpdatedAt time.Time `gorm:"column:updated_at;default:now()" bson:"updated_at"` // 更新时间
CreatedAt time.Time `gorm:"column:created_at;default:now()" bson:"created_at"` // 创建时间
Header string `gorm:"-" bson:"-"` // header
Excerpt string `gorm:"-" bson:"-"` // 预览信息
@@ -34,7 +36,7 @@ type SortedArticles []*Article
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) }
func (s SortedArticles) Less(i, j int) bool { return s[i].CreatedAt.After(s[j].CreatedAt) }
// Swap 交换
func (s SortedArticles) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

View File

@@ -3,12 +3,12 @@ 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"` // 版权声明
BlogName string `gorm:"column:blog_name;not null" bson:"blog_name"` // 博客名
SubTitle string `gorm:"column:sub_title;not null" bson:"sub_title"` // 子标题
BeiAn string `gorm:"column:bei_an;not null" bson:"bei_an"` // 备案号
BTitle string `gorm:"column:b_title;not null" bson:"b_title"` // 底部title
Copyright string `gorm:"column:copyright;not null" bson:"copyright"` // 版权声明
SeriesSay string `gorm:"not null"` // 专题说明
ArchivesSay string `gorm:"not null"` // 归档说明
SeriesSay string `gorm:"column:series_say;not null" bson:"series_say"` // 专题说明
ArchiveSay string `gorm:"column:archive_say;not null" bson:"archive_say"` // 归档说明
}

View File

@@ -5,11 +5,11 @@ import "time"
// Series 专题
type Series struct {
ID int `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()"` // 创建时间
ID int `gorm:"column:id;primaryKey" bson:"id"` // 自增ID
Slug string `gorm:"column:slug;not null;uniqueIndex" bson:"slug"` // 缩略名
Name string `gorm:"column:name;not null" bson:"name"` // 专题名
Desc string `gorm:"column:desc;not null" bson:"desc"` // 专题描述
CreatedAt time.Time `gorm:"column:created_at;default:now()" bson:"created_at"` // 创建时间
Articles SortedArticles `gorm:"-" bson:"-"` // 专题下的文章
}