package services

import (
	"github.com/gogf/gf/util/guid"
	"sparrow/pkg/models"
	"sparrow/services/knowoapi/model"
)

type SceneHisService interface {
	Create(*models.SceneHis) error
	Delete(*models.SceneHis) error
	Update(*models.SceneHis) error
	Query(int, int, string) ([]models.SceneHis, int, error)
	GetBySceneId(string) ([]models.SceneHis, error)
	Get(string) (models.SceneHis, error)
}

type sceneHisService struct {
	models *model.All
}

// NewSceneHisService new Ota manager
func NewSceneHisService(models *model.All) SceneHisService {
	return sceneHisService{
		models: models,
	}
}

func (a sceneHisService) Query(pi, ps int, sceneId string) ([]models.SceneHis, int, error) {
	return a.models.SceneHis.Query(pi, ps, sceneId)
}

func (a sceneHisService) GetBySceneId(sceneId string) ([]models.SceneHis, error) {
	return a.models.SceneHis.GetBySceneId(sceneId)
}

func (a sceneHisService) Get(recordId string) (models.SceneHis, error) {
	return a.models.SceneHis.Get(recordId)
}

func (a sceneHisService) Create(sceneHis *models.SceneHis) error {
	sceneHis.RecordId = guid.S()
	return a.models.SceneHis.Create(sceneHis)
}

func (a sceneHisService) Delete(sceneHis *models.SceneHis) error {
	return a.models.SceneHis.Delete(sceneHis)
}

func (a sceneHisService) Update(sceneHis *models.SceneHis) error {
	_, err := a.models.SceneHis.Update(sceneHis)
	return err
}
