violation.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package model
  2. import (
  3. "time"
  4. "ulink-admin/pkg/base"
  5. )
  6. type Violation struct {
  7. Id int64 `excel:"name=主键id " xorm:"pk autoincr notnull comment('主键id')" json:"id" ` //主键id
  8. Item string `excel:"name=服务项 " xorm:"varchar(255) notnull default('0') comment('服务项')" json:"item" binding:"required"` //服务项
  9. Label string `excel:"name=项目 " xorm:"varchar(255) comment('项目')" json:"label" ` //项目
  10. Content string `excel:"name=标准 " xorm:"text comment('标准')" json:"content" ` //标准
  11. Score int `excel:"name=分数 " xorm:"int(10) notnull default(0) comment('分数')" json:"score" binding:"required"` //分数
  12. CreateTime time.Time `excel:"name=创建时间 " xorm:"datetime comment('创建时间')" json:"createTime" ` //创建时间
  13. CreateBy string `excel:"name=创建人 " xorm:"varchar(255) comment('创建人')" json:"createBy" ` //创建人
  14. UpdateTime time.Time `excel:"name=更新时间 " xorm:"datetime comment('更新时间')" json:"updateTime" ` //更新时间
  15. UpdateBy string `excel:"name=更新人 " xorm:"varchar(255) comment('更新人')" json:"updateBy" ` //更新人
  16. }
  17. func (this Violation) TableName() string {
  18. return "violation"
  19. }
  20. func (this *Violation) Key() int64 {
  21. return this.Id
  22. }
  23. func (this *Violation) Model() interface{} {
  24. return this
  25. }
  26. func (this *Violation) BeforeUpdate() {
  27. user := base.GetCurUser()
  28. if user != nil {
  29. this.UpdateBy = user.Name
  30. }
  31. }
  32. func (this *Violation) BeforeInsert() {
  33. user := base.GetCurUser()
  34. if user != nil {
  35. this.CreateBy = user.Name
  36. this.UpdateBy = user.Name
  37. }
  38. }