12345678910111213141516171819202122232425262728293031323334353637383940 |
- package model
- import (
- "dy-admin/internal/pcmserver/common"
- "gorm.io/gorm"
- "strconv"
- "time"
- )
- type GridOpenLog 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'"`
- OpenState string `json:"openState" gorm:"size:128;comment:开关门"`
- common.YearMonthWeek
- common.ModelTime
- }
- type LogStatistics struct {
- StaffName string `json:"staffName"`
- Total string `json:"total"`
- }
- func (m *GridOpenLog) 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
- }
- func (m *GridOpenLog) TableName() string {
- return "bus_grid_open_logs"
- }
|