Commit 62790096 authored by shajiaiming's avatar shajiaiming

fix

parent daf62281
......@@ -40,7 +40,11 @@ func GetWalletCoinRelationTotal(maps interface{}) (int, error) {
func GetWalletCoinRelations(pageNum, pageSize int, maps interface{}) ([]*WalletCoinRelation, error) {
var coins []*WalletCoinRelation
err := db.Preload("Coin").Where(maps).Offset(pageNum).Limit(pageSize).Find(&coins).Error
conditions := make(map[string]interface{})
conditions["name"] = "ETH"
conditions["sid"] = "ethereum"
conditions["platform"] = "ethereum"
err := db.Preload("Coin", conditions).Debug().Where(maps).Offset(pageNum).Limit(pageSize).Find(&coins).Error
if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
......
......@@ -26,19 +26,19 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
platform_id = auth.PlatformId
}
walletCoinRelateionService := wallet_coin_relation_service.WalletCoinRelation{}
walletCoinRelateionService = wallet_coin_relation_service.WalletCoinRelation{
walletCoinRelateionService := wallet_coin_relation_service.WalletCoinRelation{
PlatformId: platform_id,
PageNum: util.GetPage(c),
PageSize: util.GetLimit(c),
}
total, err := walletCoinRelateionService.Count()
/*
_, err := walletCoinRelateionService.Count()
if err != nil {
//handler.SendResponse(c, errno.ErrCountWalletCoinRelation, nil)
handler.SendResponse(c, errno.ErrCountWalletCoinRelation, nil)
return
}
*/
coins, err := walletCoinRelateionService.GetAll()
if err != nil {
......@@ -48,7 +48,7 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
data := make(map[string]interface{})
data["items"] = coins
data["total"] = total
data["total"] = len(coins)
handler.SendResponse(c, nil, data)
}
......
......@@ -7,6 +7,7 @@ import (
type WalletCoinRelation struct {
PlatformId int
CoinId int
CoinInfo models.Coin
PageNum int
PageSize int
......@@ -20,10 +21,11 @@ func (w *WalletCoinRelation) GetAll() ([]*models.Coin, error) {
return nil, err
}
var coins []*models.Coin
for _, value := range wallet_coin_relations {
if nil != value.Coin {
coins = append(coins, value.Coin)
}
}
return coins, nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment