diff --git a/src/implement/public_platoon_free_punish_with_user_implement.go b/src/implement/public_platoon_free_punish_with_user_implement.go index 6a4672f..613949d 100644 --- a/src/implement/public_platoon_free_punish_with_user_implement.go +++ b/src/implement/public_platoon_free_punish_with_user_implement.go @@ -55,20 +55,14 @@ func (p PublicPlatoonFreePunishWithUserDb) PublicPlatoonFreePunishWithUserUpdate func (p PublicPlatoonFreePunishWithUserDb) PublicPlatoonFreePunishWithUserCountAndGetPageByParams(page int, limit int, params map[string]interface{}) ([]model.PublicPlatoonFreePunishWithUser, int64, error) { - var publicPlatoonFreePunishWithUser model.PublicPlatoonFreePunishWithUser - total, err := p.Db.Where("").Count(&publicPlatoonFreePunishWithUser) - if err != nil { - return nil, 0, zhios_order_relate_logx.Error(err) - } - var m []model.PublicPlatoonFreePunishWithUser - session := p.Db + var total int64 var err1 error if params != nil { query := fmt.Sprintf("%s = ?", params["key"]) - err1 = session.Where(query, params["value"]).Limit(limit, (page-1)*limit).Find(&m) + total, err1 = p.Db.Where(query, params["value"]).Limit(limit, (page-1)*limit).FindAndCount(&m) } else { - err1 = session.Where("1=1").Limit(limit, (page-1)*limit).Find(&m) + total, err1 = p.Db.Where("1=1").Limit(limit, (page-1)*limit).FindAndCount(&m) } if err1 != nil { return nil, 0, zhios_order_relate_logx.Error(err1) diff --git a/src/implement/user_virtual_amount_implement.go b/src/implement/user_virtual_amount_implement.go index d1bb31c..236555f 100644 --- a/src/implement/user_virtual_amount_implement.go +++ b/src/implement/user_virtual_amount_implement.go @@ -37,13 +37,7 @@ func (u UserVirtualAmountDb) GetUserVirtualWalletBySession(uid int64, coinId int func (u UserVirtualAmountDb) UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) { var userVirtualWallets []model.UserVirtualAmount - session := u.Db.Where("coin_id = ?", coinID) - total, err1 := session.Count(&userVirtualWallets) - if err1 != nil { - return nil, 0, zhios_order_relate_logx.Error(err1.Error()) - } - - err := session.Limit(pageSize, (page-1)*pageSize).Desc("amount").Find(&userVirtualWallets) + total, err := u.Db.Where("coin_id = ?", coinID).Limit(pageSize, (page-1)*pageSize).Desc("amount").FindAndCount(&userVirtualWallets) if err != nil { return nil, 0, zhios_order_relate_logx.Error(err.Error()) } diff --git a/src/implement/user_virtual_coin_flow_implement.go b/src/implement/user_virtual_coin_flow_implement.go index 5595024..ae5a095 100644 --- a/src/implement/user_virtual_coin_flow_implement.go +++ b/src/implement/user_virtual_coin_flow_implement.go @@ -3,7 +3,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" "xorm.io/xorm" ) @@ -30,14 +29,9 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSi session = session.And("direction = ?", direction) } - total, err1 := session.Count(&m) - if err1 != nil { - return nil, 0, zhios_order_relate_logx.Error(err1.Error()) - } - - err2 := session.Limit(pageSize, (page-1)*pageSize).Desc("create_at").Find(m) - if err2 != nil { - return nil, 0, err2 + total, err := session.Limit(pageSize, (page-1)*pageSize).Desc("create_at").FindAndCount(&m) + if err != nil { + return nil, 0, err } return m, total, nil diff --git a/src/implement/virtual_coin_implement.go b/src/implement/virtual_coin_implement.go index 46c190b..acd42e1 100644 --- a/src/implement/virtual_coin_implement.go +++ b/src/implement/virtual_coin_implement.go @@ -17,13 +17,7 @@ type VirtualCoinDb struct { func (v VirtualCoinDb) VirtualCoinFindAllAndCount(pageSize, page int) (kindList []model.VirtualCoin, total int64, err error) { var m []model.VirtualCoin - session := v.Db.Where("is_use = ?", 1) - total, err = session.Count(&m) - if err != nil { - return nil, 0, err - } - - err = session.Asc("id").Limit(pageSize, (page-1)*pageSize).Find(&m) + total, err = v.Db.Where("is_use = ?", 1).Asc("id").Limit(pageSize, (page-1)*pageSize).FindAndCount(&m) if err != nil { return nil, 0, zhios_order_relate_logx.Error(err) }