car.go 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package model
  2. import (
  3. "time"
  4. "ulink-admin/pkg/base"
  5. )
  6. type Car struct {
  7. Id int64 `excel:"name=主键id " xorm:"pk autoincr notnull comment('主键id')" json:"id" binding:"required"` //主键id
  8. CarNo string `excel:"name=车牌号 " xorm:"varchar(64) comment('车牌号')" json:"carNo" binding:"required"` //车牌号
  9. Color string `excel:"name=颜色 " xorm:"varchar(30) comment('颜色')" json:"color" ` //颜色
  10. Owner string `excel:"name=车主 " xorm:"varchar(255) comment('车主')" json:"owner" binding:"required"` //车主
  11. CompanyId int64 `excel:"name=现属公司 " xorm:"bigint(20) notnull default(0) comment('现属公司')" json:"companyId" binding:"required"` //现属公司
  12. EngineNo string `excel:"name=发动机号 " xorm:"varchar(255) comment('发动机号')" json:"engineNo" ` //发动机号
  13. ChassisNo string `excel:"name=底盘号 " xorm:"varchar(255) comment('底盘号')" json:"chassisNo" ` //底盘号
  14. ProductDate string `excel:"name=出厂日期 " xorm:"varchar(255) comment('出厂日期')" json:"productDate" ` //出厂日期
  15. Cat int64 `excel:"name=车辆类型 " xorm:"bigint(20) notnull default(2) comment('车辆类型')" json:"cat" binding:"required"` //车辆类型
  16. State int `excel:"name=营业状态 ,format=1=正常,2=注销" xorm:"int(1) notnull default(2) comment('营业状态')" json:"state" binding:"required,oneof=1 2 "` //营业状态(1正常 2注销)
  17. TransportNo string `excel:"name=运输证号 " xorm:"varchar(255) comment('运输证号')" json:"transportNo" ` //运输证号
  18. TransportDate string `excel:"name=运输证发证日期 " xorm:"varchar(255) comment('运输证发证日期')" json:"transportDate" ` //运输证发证日期
  19. Remark string `excel:"name=备注 " xorm:"text comment('备注')" json:"remark" ` //备注
  20. CreateTime time.Time `excel:"name=创建时间 " xorm:"datetime comment('创建时间')" json:"createTime" ` //创建时间
  21. CreateBy string `excel:"name=创建人 " xorm:"varchar(255) comment('创建人')" json:"createBy" ` //创建人
  22. UpdateTime time.Time `excel:"name=更新时间 " xorm:"datetime comment('更新时间')" json:"updateTime" ` //更新时间
  23. UpdateBy string `excel:"name=更新人 " xorm:"varchar(255) comment('更新人')" json:"updateBy" ` //更新人
  24. }
  25. func (this Car) TableName() string {
  26. return "car"
  27. }
  28. func (this *Car) Key() int64 {
  29. return this.Id
  30. }
  31. func (this *Car) Model() interface{} {
  32. return this
  33. }
  34. func (this *Car) BeforeUpdate() {
  35. user := base.GetCurUser()
  36. if user != nil {
  37. this.UpdateBy = user.Name
  38. }
  39. if user.ComponyId > 0 {
  40. this.CompanyId = user.ComponyId
  41. }
  42. }
  43. func (this *Car) BeforeInsert() {
  44. user := base.GetCurUser()
  45. if user != nil {
  46. this.CreateBy = user.Name
  47. this.UpdateBy = user.Name
  48. }
  49. if user.ComponyId > 0 {
  50. this.CompanyId = user.ComponyId
  51. }
  52. }