package model import ( "dy-admin/internal/pcmserver/common" "gorm.io/gorm" "strconv" "time" ) type GridWarnLog struct { common.Model DepartmentID int `json:"departmentId" gorm:"comment:'部门id'"` DepartmentName string `json:"departmentName" gorm:"size:128;comment:部门名称"` StaffID int `json:"staffId" gorm:"comment:'人员id'"` StaffName string `json:"staffName" gorm:"size:128;comment:人员名字"` CabinetID int `json:"cabinetId" gorm:"comment:'柜子id'"` CabinetName string `json:"cabinetName" gorm:"size:128;comment:柜子名字"` GridDeviceID int `json:"gridDeviceId" gorm:"comment:'格子id'"` WarnState string `json:"warnState" gorm:"size:128;comment:警告信息"` common.YearMonthWeek common.ModelTime } func (m *GridWarnLog) TableName() string { return "bus_grid_warn_logs" } func (m *GridWarnLog) BeforeCreate(_ *gorm.DB) (err error) { now := time.Now() year, week := now.ISOWeek() m.Year = year m.Month, _ = strconv.Atoi(now.Format("01")) m.Week = week return }