category.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package model
  2. import (
  3. "time"
  4. "ulink-admin/pkg/base"
  5. )
  6. type Category struct {
  7. Id int64 `excel:"name= " xorm:"pk autoincr notnull comment('')" json:"id" binding:"required"` //
  8. Label string `excel:"name=车辆类型 " xorm:"varchar(64) comment('车辆类型')" json:"label" binding:"required"` //车辆类型
  9. Sort int64 `excel:"name=排序 " xorm:"bigint(20) default(0) comment('排序')" json:"sort" binding:"required"` //排序
  10. CreateTime time.Time `excel:"name=创建时间 " xorm:"datetime comment('创建时间')" json:"createTime" ` //创建时间
  11. CreateBy string `excel:"name=创建人 " xorm:"varchar(255) comment('创建人')" json:"createBy" ` //创建人
  12. UpdateTime time.Time `excel:"name=更新时间 " xorm:"datetime comment('更新时间')" json:"updateTime" ` //更新时间
  13. UpdateBy string `excel:"name=更新人 " xorm:"varchar(255) comment('更新人')" json:"updateBy" ` //更新人
  14. }
  15. func (this Category) TableName() string {
  16. return "car_category"
  17. }
  18. func (this *Category) Key() int64 {
  19. return this.Id
  20. }
  21. func (this *Category) Model() interface{} {
  22. return this
  23. }
  24. func (this *Category) BeforeUpdate() {
  25. user := base.GetCurUser()
  26. if user != nil {
  27. this.UpdateBy = user.Name
  28. }
  29. }
  30. func (this *Category) BeforeInsert() {
  31. user := base.GetCurUser()
  32. if user != nil {
  33. this.CreateBy = user.Name
  34. this.UpdateBy = user.Name
  35. }
  36. }