49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package whitelist
|
|
|
|
import (
|
|
models "com.snow.auto_monitor/app/models/whitelist"
|
|
)
|
|
|
|
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.Whitelist, err error) {
|
|
res, _, err = models.GetInstance().GetById(id)
|
|
return
|
|
}
|
|
|
|
func Search(id int64, merchant_id int64, ip string, startTime string, endTime string, limit int, page int) (res []*models.Whitelist, err error) {
|
|
limit, page = GetLimitStart(limit, page)
|
|
res, err = models.GetInstance().Search(id, merchant_id, ip, startTime, endTime, limit, page)
|
|
return
|
|
}
|
|
|
|
func CountAll(id int64, merchant_id int64, ip string, startTime string, endTime string) (res int64, err error) {
|
|
res, err = models.GetInstance().CountAll(id, merchant_id, ip, startTime, endTime)
|
|
return
|
|
}
|
|
|
|
func Create(whitelist *models.Whitelist) (affected int64, err error) {
|
|
affected, err = models.GetInstance().Create(whitelist)
|
|
return
|
|
}
|
|
|
|
func Update(whitelist *models.Whitelist) (affected int64, err error) {
|
|
affected, err = models.GetInstance().Update(whitelist)
|
|
return
|
|
}
|
|
|
|
func Delete(id int64) (affected int64, err error) {
|
|
affected, err = models.GetInstance().Delete(id)
|
|
return
|
|
}
|