diff --git a/src/dao/egg_energy_user_activity_dao.go b/src/dao/egg_energy_user_activity_dao.go index 64a7dd9..fb91141 100644 --- a/src/dao/egg_energy_user_activity_dao.go +++ b/src/dao/egg_energy_user_activity_dao.go @@ -2,5 +2,4 @@ type EggEnergyUserActivityDao interface { //TODO:: You can add specific method definitions here - UserDailyActivityAnalysisCountByUidAndTime(startDate string, endDate string, uid ...int64) (int64, error) } diff --git a/src/dao/user_relate_dao.go b/src/dao/user_relate_dao.go index ebb839e..bedce51 100644 --- a/src/dao/user_relate_dao.go +++ b/src/dao/user_relate_dao.go @@ -7,4 +7,5 @@ type UserRelateDao interface { GetUserParentUserRelate(uid int64) (*model.UserRelate, error) FindUserRelateByParentUid(uid int64, level int) (*[]model.UserRelate, error) SumUserRelateByParentUid(parentUid string) (total int64, userRelate []*model.UserRelate, err error) + PageFindUserRelateByParentUid(uid int64, page, pageSize int) (*[]model.UserRelate, int64, error) } diff --git a/src/implement/egg_energy_user_activity_implement.go b/src/implement/egg_energy_user_activity_implement.go index 6c53cef..92dbee8 100644 --- a/src/implement/egg_energy_user_activity_implement.go +++ b/src/implement/egg_energy_user_activity_implement.go @@ -2,10 +2,6 @@ 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" - "errors" - "fmt" "xorm.io/xorm" ) @@ -16,25 +12,3 @@ func NewEggEnergyUserActivityDb(engine *xorm.Engine) dao.EggEnergyUserActivityDa type EggEnergyUserActivityDb struct { Db *xorm.Engine } - -func (e EggEnergyUserActivityDb) UserDailyActivityAnalysisCountByUidAndTime(startDate string, endDate string, uid ...int64) (int64, error) { - var m model.EggEnergyUserActivity - - var session *xorm.Session - query1 := fmt.Sprintf("uid = ?") - query2 := fmt.Sprintf("uid in ?") - if len(uid) == 1 { - session = e.Db.Where(query1, uid) - } else if len(uid) > 1 { - session = e.Db.Where(query2, uid) - } - if session == nil { - return 0, zhios_order_relate_logx.Error(errors.New("传入参数有误")) - } - - count, err := session.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/user_relate_implement.go b/src/implement/user_relate_implement.go index 69a55ff..eb82bf2 100644 --- a/src/implement/user_relate_implement.go +++ b/src/implement/user_relate_implement.go @@ -58,3 +58,16 @@ func (u UserRelateDb) SumUserRelateByParentUid(parentUid string) (total int64, u total, err = u.Db.Where("parent_uid = ?", parentUid).And("level = 1").FindAndCount(&userRelate) return } + +func (u UserRelateDb) PageFindUserRelateByParentUid(uid int64, page, pageSize int) (*[]model.UserRelate, int64, error) { + var userRelate []model.UserRelate + sess := u.Db.Where("uid = ?", uid) + total, err := sess.Count(userRelate) + if err != nil { + return nil, 0, zhios_order_relate_logx.Error(err) + } + if err := sess.Limit(pageSize, (page-1)*pageSize).Asc("level").Find(&userRelate); err != nil { + return nil, 0, zhios_order_relate_logx.Error(err) + } + return &userRelate, total, nil +}