package dao import ( "time" ) // OperationHis 操作记录 type OperationHis struct { ID int `gorm:"primary_key" json:"id"` //编号 OperationType int `gorm:"type:int" json:"operationType"` //操作类型 ModuleType int `gorm:"type:int" json:"moduleType"` //操作模块 HandleContent string `gorm:"type:varchar(1000)" json:"handleContent"` //操作内容 HandleUserId int64 `gorm:"type:bigint" json:"handleUserId"` //操作用户ID HandleTime time.Time `gorm:"type:timestamp;default CURRENT_TIMESTAMP" json:"handleTime"` //操作时间 TenantId int `gorm:"type:int" json:"tenantId"` //租户ID } func (OperationHis) TableName() string { return "t_sys_handle_his" } func (c *OperationHis) Create() error { return Db.Debug().Model(&c).Save(&c).Error } func (c OperationHis) GetHistories(offset, limit int) ([]OperationHis, error) { var list []OperationHis db := Db.Debug().Model(&c) if c.OperationType > 0 { db = db.Where("operation_type = ?", c.OperationType) } if c.ModuleType > 0 { db = db.Where("module_type = ?", c.ModuleType) } if c.HandleContent != "" { db = db.Where("handle_content like ?", "%"+c.HandleContent+"%") } err := Db.Debug().Model(&c).Offset(offset).Limit(limit).Find(&list).Error return list, err }