package rag import ( "eta/eta_api/global" "eta/eta_api/utils" "gorm.io/gorm/clause" "time" ) type ArticleKbMapping struct { Id int `gorm:"id;primaryKey"` WechatArticleId int KbId string CreatedTime time.Time UpdateTime time.Time } func (a *ArticleKbMapping) TableName() string { return "article_kb_mapping" } func GetArticleKbMapping(articleId int) (articleKbMapping *ArticleKbMapping, err error) { err = global.DbMap[utils.DbNameAI].Where("wechat_article_id = ?", articleId).First(&articleKbMapping).Error return } func CreateArticleKbMapping(articleKbMapping ArticleKbMapping) (err error) { db := global.DbMap[utils.DbNameAI] db.Clauses( clause.OnConflict{ DoNothing: true, Columns: []clause.Column{{Name: "wechat_article_id"}}, }, ) err = global.DbMap[utils.DbNameAI].Create(&articleKbMapping).Error return }