JM-WechatMini/service/system/sys_ai_kefu.go

48 lines
1.1 KiB
Go
Raw Normal View History

2023-11-10 09:30:29 +08:00
package system
import (
"miniapp/global"
"miniapp/model/common/request"
"miniapp/model/system"
)
type AiKefuService struct{}
// CreateAiKefu 创建
func (a *AiKefuService) CreateAiKefu(p *system.Aikefu) (err error) {
err = global.GVA_DB.Create(p).Error
if err == nil {
global.GVA_Kp.AddKeyWord(p.KeyWord)
}
return
}
// UpdateAiKefu 更新
func (a *AiKefuService) UpdateAiKefu(p *system.Aikefu) (err error) {
err = global.GVA_DB.Save(p).Error
return
}
// DeleteAiKefu 删除
func (a *AiKefuService) DeleteAiKefu(p *system.Aikefu) (err error) {
err = global.GVA_DB.Delete(p).Error
return
}
// GetAiKefuList 获取列表
func (a *AiKefuService) GetAiKefuList(info request.PageInfo) (list []system.Aikefu, total int64, err error) {
db := global.GVA_DB.Model(&system.Aikefu{})
err = db.Count(&total).Error
if err != nil {
return
}
err = db.Offset((info.Page - 1) * info.PageSize).Limit(info.PageSize).Find(&list).Error
return
}
// GetAiKefuById 根据id获取
func (a *AiKefuService) GetAiKefuById(id string) (p system.Aikefu, err error) {
err = global.GVA_DB.Where("id = ?", id).First(&p).Error
return
}