package models import "kefu/types" type WeworkSyncMsg struct { ID int `gorm:"primary_key;AUTO_INCREMENT"` SyncCursor string `gorm:"type:varchar(255);NOT NULL;DEFAULT:''"` JsonTxt string `gorm:"type:text;NOT NULL"` VisitorID string `gorm:"type:varchar(100);NOT NULL;DEFAULT:'';index"` KefuID string `gorm:"type:varchar(100);NOT NULL;DEFAULT:'';index"` CreatedAt types.Time `gorm:"type:timestamp;NOT NULL;DEFAULT:CURRENT_TIMESTAMP"` EntID string `gorm:"type:int(11);NOT NULL;DEFAULT:0;index"` } func (WeworkSyncMsg) TableName() string { return "wework_sync_msg" } //增加 func (this *WeworkSyncMsg) AddWeworkSyncMsg() error { return DB.Create(this).Error } //更新 func (this *WeworkSyncMsg) SaveWeworkSyncMsg(query interface{}, args ...interface{}) { DB.Model(&WeworkSyncMsg{}).Where(query, args...).Update(this) } //删除 func DelWeworkSyncMsg(query interface{}, args ...interface{}) { DB.Where(query, args...).Delete(&WeworkSyncMsg{}) } //计数 func CountWeworkSyncMsg(query interface{}, args ...interface{}) uint { var v uint DB.Table("wework_sync_msg").Where(query, args...).Count(&v) return v } //列表 func FindWeworkSyncMsgList(page, pagesize int, query interface{}, args ...interface{}) []WeworkSyncMsg { offset := (page - 1) * pagesize var res []WeworkSyncMsg DB.Table("wework_sync_msg").Where(query, args...).Order("id desc").Offset(offset).Limit(pagesize).Find(&res) return res } //单条 func FindWeworkSyncMsg(query interface{}, args ...interface{}) WeworkSyncMsg { var res WeworkSyncMsg DB.Where(query, args...).First(&res) return res }