From eaf726700d86d06714fc50ac52df1d74668836bb Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Mon, 11 Nov 2024 15:36:00 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=97=A5=E6=B4=BB=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/egg_energy_user_activity_dao.go | 2 ++ src/dao/public_platoon_user_relation_dao.go | 1 - .../egg_energy_user_activity_implement.go | 20 +++++++++++ .../public_platoon_user_relation_implement.go | 33 ------------------- 4 files changed, 22 insertions(+), 34 deletions(-) diff --git a/src/dao/egg_energy_user_activity_dao.go b/src/dao/egg_energy_user_activity_dao.go index fb91141..24305f4 100644 --- a/src/dao/egg_energy_user_activity_dao.go +++ b/src/dao/egg_energy_user_activity_dao.go @@ -2,4 +2,6 @@ type EggEnergyUserActivityDao interface { //TODO:: You can add specific method definitions here + UserDailyActivityAnalysisFindByUidAndTime(startDate string, endDate string, uid []int64) (int64, error) + UserDailyActivityAnalysisCountByUidAndTime(startDate string, endDate string, uid int64) (int64, error) } diff --git a/src/dao/public_platoon_user_relation_dao.go b/src/dao/public_platoon_user_relation_dao.go index 10871d2..d3e53fb 100644 --- a/src/dao/public_platoon_user_relation_dao.go +++ b/src/dao/public_platoon_user_relation_dao.go @@ -13,5 +13,4 @@ type PublicPlatoonUserRelationDao interface { PublicPlatoonUserRelationFindByPid(fatherUid int64, fatherName, positionName string) ([]model.PublicPlatoonUserRelation, error) PublicPlatoonUserRelationFindCountByPosition(fatherUid int64, fatherName, positionName string, startPosition, endPosition int64) ([]model.PublicPlatoonUserRelation, int64, error) PublicPlatoonUserRelationFindByParamsByPage(params map[string]interface{}, page, pageSize int) (*[]model.PublicPlatoonUserRelation, error) - PublicPlatoonUserRelationGetOneByPosition(position int64) (*model.PublicPlatoonUserRelation, error) } diff --git a/src/implement/egg_energy_user_activity_implement.go b/src/implement/egg_energy_user_activity_implement.go index 92dbee8..1e6347d 100644 --- a/src/implement/egg_energy_user_activity_implement.go +++ b/src/implement/egg_energy_user_activity_implement.go @@ -2,6 +2,8 @@ import ( "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" "xorm.io/xorm" ) @@ -12,3 +14,21 @@ func NewEggEnergyUserActivityDb(engine *xorm.Engine) dao.EggEnergyUserActivityDa type EggEnergyUserActivityDb struct { Db *xorm.Engine } + +func (e EggEnergyUserActivityDb) UserDailyActivityAnalysisFindByUidAndTime(startDate string, endDate string, uid []int64) (int64, error) { + var m model.EggEnergyUserActivity + count, err := e.Db.Where("uid in ?", uid).And("date > ?", startDate).And("date < ?", endDate).Count(&m) + if err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + return count, nil +} + +func (e EggEnergyUserActivityDb) UserDailyActivityAnalysisCountByUidAndTime(startDate string, endDate string, uid int64) (int64, error) { + var m model.EggEnergyUserActivity + count, err := e.Db.Where("uid = ?", uid).And("date > ?", startDate).And("date < ?", endDate).Count(&m) + if err != nil { + return 0, zhios_order_relate_logx.Error(err) + } + return count, nil +} diff --git a/src/implement/public_platoon_user_relation_implement.go b/src/implement/public_platoon_user_relation_implement.go index 670149f..78d5c4c 100644 --- a/src/implement/public_platoon_user_relation_implement.go +++ b/src/implement/public_platoon_user_relation_implement.go @@ -119,36 +119,3 @@ func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationFindByParamsByPage } } } - -func (p PublicPlatoonUserRelationDb) PublicPlatoonUserRelationGetOneByPosition(position int64) (*model.PublicPlatoonUserRelation, error) { - var relation model.PublicPlatoonUserRelation - _, err := p.Db.Where("position = ?", position).Get(&relation) - if err != nil { - return nil, zhios_order_relate_logx.Error(err) - } - return &relation, nil -} - -func (p PublicPlatoonUserRelationDb) GetTreeBySmall(head *model.PublicPlatoonUserRelation, leveLimit int) ([]*model.PublicPlatoonUserRelation, error) { - if leveLimit == 0 { - leveLimit = 1 - } - var res []*model.PublicPlatoonUserRelation - var queue []*model.PublicPlatoonUserRelation - queue = append(queue, head) - for len(queue) > 0 { - node := queue[0] - queue = queue[1:] - if node.Level1 > head.Level1+leveLimit { - break - } - res = append(res, node) - var son []*model.PublicPlatoonUserRelation - err1 := p.Db.Where("father_uid1 = ?", node.Uid).Find(son) - if err1 != nil { - return nil, zhios_order_relate_logx.Error(err1) - } - queue = append(queue, son...) - } - return res, nil -}