12345678910111213141516171819202122232425262728293031323334353637 |
- 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
- }
|