package models import "kefu/types" type DouyinWebhook struct { ID uint `json:"id"` KefuName string `json:"kefu_name"` Event string `json:"event"` FromUserID string `json:"from_user_id"` ToUserID string `json:"to_user_id"` ClientKey string `json:"client_key"` Content string `json:"content"` EntID string `json:"ent_id"` CreatedAt types.Time `json:"created_at"` } // CountDouyinWebhooks 返回符合条件的 DouyinWebhook 记录数量 func CountDouyinWebhooks(query interface{}, args ...interface{}) uint { var v uint DB.Table("douyin_webhook").Where(query, args...).Count(&v) return v } func FindDouyinWebhook(query interface{}, args ...interface{}) DouyinWebhook { var v DouyinWebhook DB.Table("douyin_webhook").Where(query, args...).Order("id desc").First(&v) return v } // SaveDouyinWebhook 更新 DouyinWebhook 记录 func (d *DouyinWebhook) SaveDouyinWebhook(query interface{}, args ...interface{}) error { db := DB.Table("douyin_webhook").Where(query, args...).Updates(d) return db.Error } // AddDouyinWebhook 添加新的 DouyinWebhook 记录 func (d *DouyinWebhook) AddDouyinWebhook() error { return DB.Create(d).Error } // FindDouyinWebhooks 分页查询 DouyinWebhook 记录 func FindDouyinWebhooks(page, pageSize int, query interface{}, args ...interface{}) []DouyinWebhook { offset := (page - 1) * pageSize var res []DouyinWebhook DB.Table("douyin_webhook").Where(query, args...).Order("id desc").Offset(offset).Limit(pageSize).Find(&res) return res } // DelDouyinWebhook 删除 DouyinWebhook 记录 func DelDouyinWebhook(query interface{}, args ...interface{}) error { return DB.Where(query, args...).Delete(&DouyinWebhook{}).Error }