diff --git a/src/dao/advertising_callback_dao.go b/src/dao/advertising_callback_dao.go index 4da97db..4541b2c 100644 --- a/src/dao/advertising_callback_dao.go +++ b/src/dao/advertising_callback_dao.go @@ -1,7 +1,11 @@ package dao -import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "xorm.io/xorm" +) type AdvertisingCallbackDao interface { FindAdvertisingCallbackAndTotal(page, limit, amount, uid, startTime, endTime, platform, types string) (*[]model.AdvertisingCallback, int64, error) + AdvertisingCallbackCountBySession(session *xorm.Session, uid, startTime, endTime, types string) (int64, error) } diff --git a/src/implement/advertising_callback_implement.go b/src/implement/advertising_callback_implement.go index c602763..13ea86e 100644 --- a/src/implement/advertising_callback_implement.go +++ b/src/implement/advertising_callback_implement.go @@ -44,3 +44,24 @@ func (a AdvertisingCallbackDb) FindAdvertisingCallbackAndTotal(page, limit, amou } return &m, count, nil } + +func (a AdvertisingCallbackDb) AdvertisingCallbackCountBySession(session *xorm.Session, uid, startTime, endTime, types string) (int64, error) { + sess := session.Where("1=1") + if uid != "" { + sess.And("uid=?", uid) + } + if types != "" { + sess.And("type=?", types) + } + if startTime != "" { + sess.And("create_at>=?", startTime) + } + if endTime != "" { + sess.And("create_at<=?", endTime) + } + count, err := sess.Count(&model.AdvertisingCallback{}) + if err != nil { + return 0, err + } + return count, nil +}