go-wxhelper/service/aiassistant/select.go
2024-02-02 17:30:11 +08:00

24 lines
642 B
Go

package aiassistant
import (
"wechat-robot/internal/database"
"wechat-robot/model/entity"
param "wechat-robot/model/param/aiassistant"
)
// GetAll
// @description: 获取所有AI助手
// @param p param.GetAll 查询参数
// @return records []entity.AiAssistant 查询结果
// @return err error 查询错误
func GetAll(p param.GetAll) (records []entity.AiAssistant, err error) {
tx := database.Client.Order("created_at DESC")
if p.Keyword != "" {
// 关键字模糊匹配,从名称和人设中找
tx.Where("name LIKE ? OR personality LIKE ?", "%"+p.Keyword+"%", "%"+p.Keyword+"%")
}
err = tx.Find(&records).Error
return
}