diff --git a/.example/frame/mvc/app/model/article/article_entity.go b/.example/frame/mvc/app/model/article/article_entity.go index 8b302e6e8..94bb8f876 100644 --- a/.example/frame/mvc/app/model/article/article_entity.go +++ b/.example/frame/mvc/app/model/article/article_entity.go @@ -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() -} +} \ No newline at end of file diff --git a/.example/frame/mvc/app/model/article/article_model.go b/.example/frame/mvc/app/model/article/article_model.go index 7b5c6246d..90561ed3e 100644 --- a/.example/frame/mvc/app/model/article/article_model.go +++ b/.example/frame/mvc/app/model/article/article_model.go @@ -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) }) -} +} \ No newline at end of file