package wallet_coin_relation_service

import (
	"bwallet/models"
)

type WalletCoinRelation struct {
	PlatformId int
	CoinId     int

	PageNum  int
	PageSize int
}

func (w *WalletCoinRelation) GetAll() ([]*models.WalletCoinRelation, error) {
	var coins []*models.WalletCoinRelation

	coins, err := models.GetWalletCoinRelations(w.PageNum, w.PageSize, w.getMaps())
	if err != nil {
		return nil, err
	}

	return coins, nil
}

func (w *WalletCoinRelation) Count() (int, error) {
	return models.GetWalletCoinRelationTotal(w.getMaps())
}

func (c *WalletCoinRelation) getMaps() (map[string]interface{}) {
	maps := make(map[string]interface{})

	//if c.PlatformId != 0 {
	//	maps["platform_id"] = c.PlatformId
	//}

	if c.CoinId != 0 {
		maps["coin_id"] = c.CoinId
	}

	return maps
}
