This commit is contained in:
John
2019-12-16 21:22:42 +08:00
parent 76bc9bd385
commit 4facdd5c9e
2 changed files with 19 additions and 16 deletions

View File

@ -12,21 +12,24 @@ import (
// Entity is the golang structure for table gf_article.
type Entity struct {
Id int `orm:"id,primary" json:"id"` //
CatId int `orm:"cat_id" json:"cat_id"` // 分类ID
Uid int `orm:"uid" json:"uid"` // 用户ID
Title string `orm:"title" json:"title"` // 标题
Content string `orm:"content" json:"content"` // 内容
Order int `orm:"order" json:"order"` // 排序
Brief string `orm:"brief" json:"brief"` // 摘要
Thumb string `orm:"thumb" json:"thumb"` // 缩略图
Tags string `orm:"tags" json:"tags"` // 标签
Referer string `orm:"referer" json:"referer"` // 内容来源
Status int `orm:"status" json:"status"` // 状态\n0: 禁用\n1: 正常
CreateTime *gtime.Time `orm:"create_time" json:"create_time"` // 创建时间
UpdateTime *gtime.Time `orm:"update_time" json:"update_time"` // 修改时间
Id int `orm:"id,primary" json:"id"` //
CatId int `orm:"cat_id" json:"cat_id"` // 分类ID
Uid int `orm:"uid" json:"uid"` // 用户ID
Title string `orm:"title" json:"title"` // 标题
Content string `orm:"content" json:"content"` // 内容
Order int `orm:"order" json:"order"` // 排序
Brief string `orm:"brief" json:"brief"` // 摘要
Thumb string `orm:"thumb" json:"thumb"` // 缩略图
Tags string `orm:"tags" json:"tags"` // 标签
Referer string `orm:"referer" json:"referer"` // 内容来源
Status int `orm:"status" json:"status"` // 状态\n0: 禁用\n1: 正常
CreateTime *gtime.Time `orm:"create_time" json:"create_time"` // 创建时间
UpdateTime *gtime.Time `orm:"update_time" json:"update_time"` // 修改时间
}
// Article is alias of Entity, which some developers say they just want.
type Article = Entity
// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
// the data and where attributes for empty values.
func (r *Entity) OmitEmpty() *arModel {
@ -62,4 +65,4 @@ func (r *Entity) Update() (result sql.Result, err error) {
// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
func (r *Entity) Delete() (result sql.Result, err error) {
return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
}
}

View File

@ -21,7 +21,7 @@ var (
Table = "gf_article"
// Model is the model object of gf_article.
Model = &arModel{g.DB("default").Table(Table).Safe()}
// Primary is the primary field name of table gf_article.
// Primary is the primary key name of table gf_article.
Primary = gdb.GetPrimaryKey(new(Entity))
)
@ -325,4 +325,4 @@ func (m *arModel) Chunk(limit int, callback func(entities []*Entity, err error)
}
return callback(entities, err)
})
}
}