package rag import ( "eta/eta_api/global" "eta/eta_api/utils" "time" ) type PromoteTrainRecord struct { Id int `gorm:"id;primaryKey"` Title string `gorm:"title"` WechatArticleId int `gorm:"wechat_article_id"` TemplatePromote string `gorm:"template_promote"` PromoteSendTime time.Time `gorm:"promote_send_time"` AigcContent string `gorm:"aigc_content"` AigcSendTime time.Time `gorm:"aigc_send_time"` IsDeleted bool `gorm:"is_deleted"` CreatedTime time.Time `gorm:"created_time"` UpdateTime time.Time `gorm:"update_time"` } func (p *PromoteTrainRecord) ToView() *PromoteTrainRecordView { return &PromoteTrainRecordView{ Id: p.Id, Title: p.Title, WechatArticleId: p.WechatArticleId, TemplatePromote: p.TemplatePromote, PromoteSendTime: p.PromoteSendTime.Format(utils.FormatDateTime), AigcContent: p.AigcContent, AigcSendTime: p.AigcSendTime.Format(utils.FormatDateTime), } } type PromoteTrainRecordView struct { Id int Title string WechatArticleId int TemplatePromote string PromoteSendTime string AigcContent string AigcSendTime string } func (p *PromoteTrainRecord) TableName() string { return "promote_train_record" } func (p *PromoteTrainRecord) SaveContent() error { return global.DbMap[utils.DbNameAI].Create(p).Error } func DeleteContent(id int) error { return global.DbMap[utils.DbNameAI].Model(&PromoteTrainRecord{}).Where("id = ?", id).Update("is_deleted", true).Error } func GetRecordList(wechatArticleId int) (list []*PromoteTrainRecordView, err error) { var ormList []PromoteTrainRecord err = global.DbMap[utils.DbNameAI].Model(&PromoteTrainRecord{}).Where("wechat_article_id = ? and is_deleted=?", wechatArticleId, false).Order(`created_time DESC`).Find(&ormList).Error if err != nil { return } for _, item := range ormList { list = append(list, item.ToView()) } return }