package models import ( "kefu/types" "time" ) type Fly_log struct { ID uint `gorm:"primary_key" json:"id"` EntId string `json:"ent_id"` IpAddress string `json:"ip_address"` LogContent string `json:"log_content"` LogType string `json:"log_type"` CreatedAt types.Time `json:"created_at"` } func CreateFlyLog(entId, ipAddress, logContent, logType string) *Fly_log { v := &Fly_log{ EntId: entId, IpAddress: ipAddress, LogContent: logContent, LogType: logType, CreatedAt: types.Time{time.Now()}, } DB.Create(v) return v } func CountFlyLog(query interface{}, args ...interface{}) uint { var v uint DB.Table("fly_log").Where(query, args...).Count(&v) return v } func FindFlyLogs(page, pagesize int, query interface{}, args ...interface{}) []Fly_log { offset := (page - 1) * pagesize var res []Fly_log DB.Table("fly_log").Where(query, args...).Order("id desc").Offset(offset).Limit(pagesize).Find(&res) return res }