grid_warn_log.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package model
  2. import (
  3. "dy-admin/internal/pcmserver/common"
  4. "gorm.io/gorm"
  5. "strconv"
  6. "time"
  7. )
  8. type GridWarnLog struct {
  9. common.Model
  10. DepartmentID int `json:"departmentId" gorm:"comment:'部门id'"`
  11. DepartmentName string `json:"departmentName" gorm:"size:128;comment:部门名称"`
  12. StaffID int `json:"staffId" gorm:"comment:'人员id'"`
  13. StaffName string `json:"staffName" gorm:"size:128;comment:人员名字"`
  14. CabinetID int `json:"cabinetId" gorm:"comment:'柜子id'"`
  15. CabinetName string `json:"cabinetName" gorm:"size:128;comment:柜子名字"`
  16. GridDeviceID int `json:"gridDeviceId" gorm:"comment:'格子id'"`
  17. WarnState string `json:"warnState" gorm:"size:128;comment:警告信息"`
  18. common.YearMonthWeek
  19. common.ModelTime
  20. }
  21. func (m *GridWarnLog) TableName() string {
  22. return "bus_grid_warn_logs"
  23. }
  24. func (m *GridWarnLog) BeforeCreate(_ *gorm.DB) (err error) {
  25. now := time.Now()
  26. year, week := now.ISOWeek()
  27. m.Year = year
  28. m.Month, _ = strconv.Atoi(now.Format("01"))
  29. m.Week = week
  30. return
  31. }