package model import ( "time" "ulink-admin/pkg/base" ) type DocFile struct { Id int64 `excel:"name= " xorm:"pk autoincr notnull comment('')" json:"id" binding:"required"` // CatgoryId int64 `excel:"name=分类id " xorm:"bigint(20) comment('分类id')" json:"catgoryId" ` //分类id UserId int64 `excel:"name=分类id " xorm:"bigint(20) comment('分类id')" json:"userId" ` //分类id Label string `excel:"name=标题 " xorm:"varchar(64) comment('标题')" json:"label" binding:"required"` //标题 Keywords string `excel:"name=关键字 " xorm:"varchar(255) comment('关键字')" json:"keywords" ` //关键字 Info string `excel:"name=简介 " xorm:"varchar(255) comment('简介')" json:"info" ` //简介 Content string `excel:"name=内容 " xorm:"longtext comment('内容')" json:"content" binding:"required"` //内容 File string `excel:"name=附件 " xorm:"text comment('附件')" json:"file" ` //附件 State int `excel:"name=状态 ,format=1=禁用,2=启用" xorm:"int(1) notnull default(2) comment('状态')" json:"state" ` //状态(1禁用 2启用) Sort int64 `excel:"name=排序 " xorm:"bigint(20) default(0) comment('排序')" json:"sort" ` //排序 CreateTime time.Time `excel:"name=创建时间 " xorm:"datetime comment('创建时间')" json:"createTime" ` //创建时间 CreateBy string `excel:"name=创建人 " xorm:"varchar(255) comment('创建人')" json:"createBy" ` //创建人 UpdateTime time.Time `excel:"name=更新时间 " xorm:"datetime comment('更新时间')" json:"updateTime" ` //更新时间 UpdateBy string `excel:"name=更新人 " xorm:"varchar(255) comment('更新人')" json:"updateBy" ` //更新人 CompanyId int64 `excel:"name=公司id " xorm:"bigint(20) comment('公司id')" json:"companyId" ` //公司id } func (this DocFile) TableName() string { return "doc_file" } func (this *DocFile) Key() int64 { return this.Id } func (this *DocFile) Model() interface{} { return this } func (this *DocFile) BeforeUpdate() { user := base.GetCurUser() if user != nil { this.UpdateBy = user.Name } if user.ComponyId > 0 { this.CompanyId = user.ComponyId } } func (this *DocFile) BeforeInsert() { user := base.GetCurUser() if user != nil { this.CreateBy = user.Name this.UpdateBy = user.Name } if user.ComponyId > 0 { this.CompanyId = user.ComponyId } }