package device import ( models "com.snow.auto_monitor/app/models/device" ) func GetLimitStart(limit int, page int) (int, int) { if limit <= 0 { limit = 20 } if page > 0 { page = (page - 1) * limit } else { page = 0 } return limit, page } func GetById(id int64) (res *models.Device, err error) { res, _, err = models.GetInstance().GetById(id) return } // func Search(id int64, name string, startTime string, endTime string, limit int, page int) (res []*models.Device, err error) { // limit, page = GetLimitStart(limit, page) // res, err = models.GetInstance().Search(id, name, startTime, endTime, limit, page) // return // } // func CountAll(id int64, name string, startTime string, endTime string) (res int64, err error) { // res, err = models.GetInstance().CountAll(id, name, startTime, endTime) // return // } func Create(device *models.Device) (affected int64, err error) { affected, err = models.GetInstance().Create(device) return } func Update(device *models.Device) (affected int64, err error) { affected, err = models.GetInstance().Update(device) return } func Delete(id int64) (affected int64, err error) { affected, err = models.GetInstance().Delete(id) return }