2024-01-19 12:06:30 +08:00
|
|
|
package robot
|
2024-02-05 15:21:36 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"wechat-robot/internal/database"
|
|
|
|
"wechat-robot/model/entity"
|
|
|
|
robotParam "wechat-robot/model/param/robot"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetAll
|
|
|
|
// @description: 查询所有机器人
|
|
|
|
// @param p robotParam.GetAll 查询所有机器人入参
|
|
|
|
// @return records []entity.Robot 查询所有机器人返回值
|
|
|
|
// @return err error 查询所有机器人返回值
|
|
|
|
func GetAll(p robotParam.GetAll) (records []entity.Robot, err error) {
|
|
|
|
tx := database.Client.Order("created_at desc")
|
|
|
|
if p.Keyword != "" {
|
|
|
|
tx.Where("nickname LIKE @keyword OR remark LIKE @keyword", sql.Named("keyword", "%"+p.Keyword+"%"))
|
|
|
|
}
|
|
|
|
if p.Tag != "" {
|
|
|
|
tx.Where("tag LIKE ?", "%"+p.Tag+"%")
|
|
|
|
}
|
|
|
|
err = tx.Find(&records).Error
|
|
|
|
return
|
|
|
|
}
|