package app import ( "go.uber.org/zap" "miniapp/global" "miniapp/model/app/request" "miniapp/model/system" ) type AiKefuService struct{} // MatchKeywordReplyContent 匹配关键词回复内容 func (a *AiKefuService) MatchKeywordReplyContent(msg request.Msg) (kf system.Aikefu, err error) { math := global.GVA_Kp.ExtractKeywords(msg.Msg) if len(math) == 0 { return } err = global.GVA_DB.Where("key_word like ? ", "%"+math[0].MatchString()+"%").First(&kf).Error return } func (a *AiKefuService) AddKeyWord() { var keyWords []system.Aikefu err := global.GVA_DB.Find(&keyWords).Error if err != nil { global.GVA_LOG.Error("初始化分词器时查询关键词失败:", zap.Error(err)) } for _, keyWord := range keyWords { global.GVA_Kp.AddKeyWord(keyWord.KeyWord) global.GVA_LOG.Info("初始化分词器时添加关键词", zap.String("keyWord", keyWord.KeyWord)) } }