package model import ( "time" "ulink-admin/pkg/base" ) type Category struct { Id int64 `excel:"name= " xorm:"pk autoincr notnull comment('')" json:"id" binding:"required"` // Label string `excel:"name=车辆类型 " xorm:"varchar(64) comment('车辆类型')" json:"label" binding:"required"` //车辆类型 Sort int64 `excel:"name=排序 " xorm:"bigint(20) default(0) comment('排序')" json:"sort" binding:"required"` //排序 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" ` //更新人 } func (this Category) TableName() string { return "car_category" } func (this *Category) Key() int64 { return this.Id } func (this *Category) Model() interface{} { return this } func (this *Category) BeforeUpdate() { user := base.GetCurUser() if user != nil { this.UpdateBy = user.Name } } func (this *Category) BeforeInsert() { user := base.GetCurUser() if user != nil { this.CreateBy = user.Name this.UpdateBy = user.Name } }