package admin

import (
	"server/dao"
	"server/model/common/request"
)

type DeviceService struct{}

func (ds *DeviceService) QueryAllDevices() ([]dao.Device, error) {
	return dao.QueryAllDevices()
}

func (ds *DeviceService) QueryDeviceList(info request.DeviceSearch) ([]dao.Device, int64, error) {
	limit := info.PageInfo.PageSize
	offset := info.PageInfo.PageSize * (info.PageInfo.Page - 1)
	return dao.QueryDeviceList(info.Sn, info.Name, info.Genre, limit, offset)
}

func (ds *DeviceService) CreateDevice(device dao.Device) error {
	return device.CreateDevice()
}

func (ds *DeviceService) UpdateDevice(device dao.Device) error {
	return device.UpdateDevice()
}

func (ds *DeviceService) DeleteDevice(id int) error {
	return dao.DeleteDevice(id)
}
