com.snow.auto_monitor/app/services/device/device.go

49 lines
1.2 KiB
Go
Raw Normal View History

2024-08-07 13:46:10 +08:00
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
}
2024-08-07 15:31:24 +08:00
func Search(id int64, device_no string,phone string,code int64, startTime string, endTime string, limit int, page int) (res []*models.Device, err error) {
limit, page = GetLimitStart(limit, page)
res, err = models.GetInstance().Search(id, device_no,phone,code, startTime, endTime, limit, page)
return
}
func CountAll(id int64, device_no string,phone string,code int64, startTime string, endTime string) (res int64, err error) {
res, err = models.GetInstance().CountAll(id, device_no,phone,code, startTime, endTime)
return
}
2024-08-07 13:46:10 +08:00
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
}