From 9c0299d2292a7a485d285f308eb73c9333451a2a Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 19 Dec 2024 14:13:02 +0800 Subject: [PATCH 1/4] update --- src/dao/advertising_callback_dao.go | 6 ++++- .../advertising_callback_implement.go | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/dao/advertising_callback_dao.go b/src/dao/advertising_callback_dao.go index 4da97db..567d4c1 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) + AdvertisingCallbackExistBySession(session *xorm.Session, uid, startTime, endTime, types string) (bool, error) } diff --git a/src/implement/advertising_callback_implement.go b/src/implement/advertising_callback_implement.go index c602763..e80dab8 100644 --- a/src/implement/advertising_callback_implement.go +++ b/src/implement/advertising_callback_implement.go @@ -44,3 +44,25 @@ func (a AdvertisingCallbackDb) FindAdvertisingCallbackAndTotal(page, limit, amou } return &m, count, nil } + +func (a AdvertisingCallbackDb) AdvertisingCallbackExistBySession(session *xorm.Session, uid, startTime, endTime, types string) (bool, error) { + var m []model.AdvertisingCallback + 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) + } + exist, err := sess.Exist(&m) + if err != nil { + return false, err + } + return exist, nil +} From 340ce34a0fa997c83b199e26b07ee352020ce114 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 19 Dec 2024 14:35:36 +0800 Subject: [PATCH 2/4] fix team assistance count --- src/dao/advertising_callback_dao.go | 2 +- src/implement/advertising_callback_implement.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dao/advertising_callback_dao.go b/src/dao/advertising_callback_dao.go index 567d4c1..4541b2c 100644 --- a/src/dao/advertising_callback_dao.go +++ b/src/dao/advertising_callback_dao.go @@ -7,5 +7,5 @@ import ( type AdvertisingCallbackDao interface { FindAdvertisingCallbackAndTotal(page, limit, amount, uid, startTime, endTime, platform, types string) (*[]model.AdvertisingCallback, int64, error) - AdvertisingCallbackExistBySession(session *xorm.Session, uid, startTime, endTime, types string) (bool, 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 e80dab8..1a2d60a 100644 --- a/src/implement/advertising_callback_implement.go +++ b/src/implement/advertising_callback_implement.go @@ -45,7 +45,7 @@ func (a AdvertisingCallbackDb) FindAdvertisingCallbackAndTotal(page, limit, amou return &m, count, nil } -func (a AdvertisingCallbackDb) AdvertisingCallbackExistBySession(session *xorm.Session, uid, startTime, endTime, types string) (bool, error) { +func (a AdvertisingCallbackDb) AdvertisingCallbackCountBySession(session *xorm.Session, uid, startTime, endTime, types string) (int64, error) { var m []model.AdvertisingCallback sess := session.Where("1=1") if uid != "" { @@ -60,9 +60,9 @@ func (a AdvertisingCallbackDb) AdvertisingCallbackExistBySession(session *xorm.S if endTime != "" { sess.And("create_at<=?", endTime) } - exist, err := sess.Exist(&m) + count, err := sess.Count(&m) if err != nil { return false, err } - return exist, nil + return count, nil } From 64f53e54701edb59999073b57c25d06b6f6af85f Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 19 Dec 2024 14:41:52 +0800 Subject: [PATCH 3/4] update --- src/implement/advertising_callback_implement.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/implement/advertising_callback_implement.go b/src/implement/advertising_callback_implement.go index 1a2d60a..a2c4536 100644 --- a/src/implement/advertising_callback_implement.go +++ b/src/implement/advertising_callback_implement.go @@ -62,7 +62,7 @@ func (a AdvertisingCallbackDb) AdvertisingCallbackCountBySession(session *xorm.S } count, err := sess.Count(&m) if err != nil { - return false, err + return 0, err } return count, nil } From 3ff292c78b7530e0e994870f652417fa53fecce5 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Thu, 19 Dec 2024 14:57:21 +0800 Subject: [PATCH 4/4] update --- src/implement/advertising_callback_implement.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/implement/advertising_callback_implement.go b/src/implement/advertising_callback_implement.go index a2c4536..13ea86e 100644 --- a/src/implement/advertising_callback_implement.go +++ b/src/implement/advertising_callback_implement.go @@ -46,7 +46,6 @@ func (a AdvertisingCallbackDb) FindAdvertisingCallbackAndTotal(page, limit, amou } func (a AdvertisingCallbackDb) AdvertisingCallbackCountBySession(session *xorm.Session, uid, startTime, endTime, types string) (int64, error) { - var m []model.AdvertisingCallback sess := session.Where("1=1") if uid != "" { sess.And("uid=?", uid) @@ -60,7 +59,7 @@ func (a AdvertisingCallbackDb) AdvertisingCallbackCountBySession(session *xorm.S if endTime != "" { sess.And("create_at<=?", endTime) } - count, err := sess.Count(&m) + count, err := sess.Count(&model.AdvertisingCallback{}) if err != nil { return 0, err }