package impl

import (
	"ai_scheduler/internal/data/model"
	"ai_scheduler/tmpl/dataTemp"
	"ai_scheduler/utils"
	"database/sql"
)

type BotGroupImpl struct {
	dataTemp.DataTemp
}

func NewBotGroupImpl(db *utils.Db) *BotGroupImpl {
	return &BotGroupImpl{
		DataTemp: *dataTemp.NewDataTemp(db, new(model.AiBotGroup)),
	}
}

func (k BotGroupImpl) GetByConversationIdAndRobotCode(staffId string, robotCode string) (*model.AiBotGroup, error) {
	var data model.AiBotGroup
	err := k.Db.Model(k.Model).Where("conversation_id = ? and robot_code = ? and status = 1", staffId, robotCode).Find(&data).Error
	if data.GroupID == 0 {
		err = sql.ErrNoRows
	}
	return &data, err
}
