package fms

import (
	"github.com/beego/beego/v2/client/orm"
)

// CurrencyUnit 货币单位表
type CurrencyUnit struct {
	CurrencyUnitId int    `gorm:"primaryKey;column:currency_unit_id" json:"-" description:"货币ID"`
	Name           string `gorm:"column:name" json:"name" description:"货币名称"`
	UnitName       string `gorm:"unit_name" json:"unit_name" description:"单位名称"`
	Code           string `gorm:"code" json:"code" description:"国际代码"`
	Enable         int    `gorm:"enable" json:"enable" description:"状态: 0-禁用; 1-启用"`
	FlagImg        string `gorm:"flag_img" json:"flag_img" description:"国旗图片"`
}

func (m *CurrencyUnit) TableName() string {
	return "currency_unit"
}

func (m *CurrencyUnit) List(condition string, pars []interface{}) (list []*CurrencyUnit, err error) {
	o := orm.NewOrmUsingDB("fms")
	sql := `SELECT * FROM currency_unit  WHERE  `
	sql += condition
	sql += ` ORDER BY currency_unit_id ASC `
	_,err = o.Raw(sql, pars).QueryRows(&list)

	return
}

type CurrencyUnitItem struct {
	Name     string  `json:"name" description:"货币名称"`
	UnitName string  `json:"unit_name" description:"单位名称"`
	Code     string  `json:"code" description:"国际代码"`
	Enable   int     `json:"enable" description:"状态: 0-禁用; 1-启用"`
	RMBRate  float64 `json:"rmb_rate" description:"当日对人民币汇率"`
	FlagImg  string  `json:"flag_img" description:"国旗图片"`
}
