49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
|
package merchant
|
||
|
|
||
|
import (
|
||
|
models "com.snow.auto_monitor/app/models/merchant"
|
||
|
)
|
||
|
|
||
|
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.Merchant, 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.Merchant, 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(merchant *models.Merchant) (affected int64, err error) {
|
||
|
affected, err = models.GetInstance().Create(merchant)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func Update(merchant *models.Merchant) (affected int64, err error) {
|
||
|
affected, err = models.GetInstance().Update(merchant)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func Delete(id int64) (affected int64, err error) {
|
||
|
affected, err = models.GetInstance().Delete(id)
|
||
|
return
|
||
|
}
|