@@ -55,20 +55,14 @@ func (p PublicPlatoonFreePunishWithUserDb) PublicPlatoonFreePunishWithUserUpdate | |||||
func (p PublicPlatoonFreePunishWithUserDb) PublicPlatoonFreePunishWithUserCountAndGetPageByParams(page int, limit int, params map[string]interface{}) ([]model.PublicPlatoonFreePunishWithUser, int64, error) { | 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 | var m []model.PublicPlatoonFreePunishWithUser | ||||
session := p.Db | |||||
var total int64 | |||||
var err1 error | var err1 error | ||||
if params != nil { | if params != nil { | ||||
query := fmt.Sprintf("%s = ?", params["key"]) | 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 { | } 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 { | if err1 != nil { | ||||
return nil, 0, zhios_order_relate_logx.Error(err1) | return nil, 0, zhios_order_relate_logx.Error(err1) | ||||
@@ -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) { | func (u UserVirtualAmountDb) UserVirtualAmountFindAndCountByCoinKind(coinID int, page, pageSize int) ([]model.UserVirtualAmount, int64, error) { | ||||
var userVirtualWallets []model.UserVirtualAmount | 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 { | if err != nil { | ||||
return nil, 0, zhios_order_relate_logx.Error(err.Error()) | return nil, 0, zhios_order_relate_logx.Error(err.Error()) | ||||
} | } | ||||
@@ -3,7 +3,6 @@ | |||||
import ( | import ( | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" | ||||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | "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" | "xorm.io/xorm" | ||||
) | ) | ||||
@@ -30,14 +29,9 @@ func (u UserVirtualCoinFlowDb) UserVirtualCoinFlowFindByCoinAndUser(page, pageSi | |||||
session = session.And("direction = ?", direction) | 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 | return m, total, nil | ||||
@@ -17,13 +17,7 @@ type VirtualCoinDb struct { | |||||
func (v VirtualCoinDb) VirtualCoinFindAllAndCount(pageSize, page int) (kindList []model.VirtualCoin, total int64, err error) { | func (v VirtualCoinDb) VirtualCoinFindAllAndCount(pageSize, page int) (kindList []model.VirtualCoin, total int64, err error) { | ||||
var m []model.VirtualCoin | 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 { | if err != nil { | ||||
return nil, 0, zhios_order_relate_logx.Error(err) | return nil, 0, zhios_order_relate_logx.Error(err) | ||||
} | } | ||||