package models import ( "kefu/types" "time" ) type AigcSessionCollect struct { ID uint `gorm:"primary_key" json:"id"` EntId string `json:"ent_id"` KefuName string `json:"kefu_name"` Title string `json:"title"` CreatedAt types.Time `json:"created_at"` } func CreateAigcSessionCollect(title, entId, kefuName string) uint { v := &AigcSessionCollect{ Title: title, EntId: entId, KefuName: kefuName, CreatedAt: types.Time{Time: time.Now()}, } DB.Create(v) return v.ID } func FindAigcSessionCollects(page, pagesize int, query interface{}, args ...interface{}) []AigcSessionCollect { offset := (page - 1) * pagesize var res []AigcSessionCollect DB.Table("aigc_session_collect").Where(query, args...).Order("id desc").Offset(offset).Limit(pagesize).Find(&res) return res } // 单条 func FindAigcSessionCollect(query interface{}, args ...interface{}) AigcSessionCollect { var res AigcSessionCollect DB.Where(query, args...).First(&res) return res } func DelAigcSessionCollects(query interface{}, args ...interface{}) error { DB.Where(query, args...).Delete(&AigcSessionCollect{}) DB.Where(query, args...).Delete(&AigcSessionMessage{}) return nil }