Commit 62790096 authored by shajiaiming's avatar shajiaiming

fix

parent daf62281
...@@ -40,7 +40,11 @@ func GetWalletCoinRelationTotal(maps interface{}) (int, error) { ...@@ -40,7 +40,11 @@ func GetWalletCoinRelationTotal(maps interface{}) (int, error) {
func GetWalletCoinRelations(pageNum, pageSize int, maps interface{}) ([]*WalletCoinRelation, error) { func GetWalletCoinRelations(pageNum, pageSize int, maps interface{}) ([]*WalletCoinRelation, error) {
var coins []*WalletCoinRelation 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 { if err != nil && err != gorm.ErrRecordNotFound {
return nil, err return nil, err
} }
......
...@@ -26,19 +26,19 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) { ...@@ -26,19 +26,19 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
platform_id = auth.PlatformId 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, PlatformId: platform_id,
PageNum: util.GetPage(c), PageNum: util.GetPage(c),
PageSize: util.GetLimit(c), PageSize: util.GetLimit(c),
} }
total, err := walletCoinRelateionService.Count() /*
_, err := walletCoinRelateionService.Count()
if err != nil { if err != nil {
//handler.SendResponse(c, errno.ErrCountWalletCoinRelation, nil) handler.SendResponse(c, errno.ErrCountWalletCoinRelation, nil)
return return
} }
*/
coins, err := walletCoinRelateionService.GetAll() coins, err := walletCoinRelateionService.GetAll()
if err != nil { if err != nil {
...@@ -48,7 +48,7 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) { ...@@ -48,7 +48,7 @@ func GetWalletCoinRelationCoinRelations(c *gin.Context) {
data := make(map[string]interface{}) data := make(map[string]interface{})
data["items"] = coins data["items"] = coins
data["total"] = total data["total"] = len(coins)
handler.SendResponse(c, nil, data) handler.SendResponse(c, nil, data)
} }
......
...@@ -5,8 +5,9 @@ import ( ...@@ -5,8 +5,9 @@ import (
) )
type WalletCoinRelation struct { type WalletCoinRelation struct {
PlatformId int PlatformId int
CoinId int CoinId int
CoinInfo models.Coin
PageNum int PageNum int
PageSize int PageSize int
...@@ -20,9 +21,10 @@ func (w *WalletCoinRelation) GetAll() ([]*models.Coin, error) { ...@@ -20,9 +21,10 @@ func (w *WalletCoinRelation) GetAll() ([]*models.Coin, error) {
return nil, err return nil, err
} }
var coins []*models.Coin var coins []*models.Coin
for _, value := range wallet_coin_relations { for _, value := range wallet_coin_relations {
coins = append(coins, value.Coin) if nil != value.Coin {
coins = append(coins, value.Coin)
}
} }
return coins, nil 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