package models

import (
	"bwallet/pkg/setting"
	"github.com/jinzhu/gorm"
)

type Currency struct {
	Model

	Id       int    `json:"primary_key,omitempty"`
	PjId     int    `json:"pj_id,omitempty"`
	PjName   string `json:"pj_name"`
	PjSymbol string `json:"pj_symbol,omitempty"`
	Lang     string `json:"lang,omitempty"`
	symbol   string `json:"symbol,omitempty"`
}

func (c Currency) TableName() string {
	return setting.DatabaseSetting.Name_Sources + ".coin_currency"
}

/**
 * 获取符合条件的信息
 * @return
 */
func GetCurrencies() ([]*Currency, error) {
	var currencies []*Currency

	err := db.Select("id, pj_name").Find(&currencies).Error
	if err != nil && err != gorm.ErrRecordNotFound {
		return nil, err
	}

	return currencies, nil
}
