Skip to content

Commit

Permalink
utils.DeciStr
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 27, 2023
1 parent 7b94690 commit ca576ae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
34 changes: 17 additions & 17 deletions cmd/haobase/base/varieties/symbol.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@ type Varieties struct {
}

type TradingVarieties struct {
Id int `xorm:"pk autoincr int" json:"id"`
Symbol string `xorm:"varchar(100) notnull unique(symbol)" json:"symbol"`
Name string `xorm:"varchar(250) notnull" json:"name"`
TargetSymbolId int `xorm:"default(0) unique(symbol_base)" json:"target_symbol_id"` //交易物品
BaseSymbolId int `xorm:"default(0) unique(symbol_base)" json:"base_symbol_id"` //支付货币
PricePrecision int `xorm:"default(2)" json:"price_precision"`
QtyPrecision int `xorm:"default(0)" json:"qty_precision"`
AllowMinQty utils.FloatString `xorm:"decimal(40,20) default(0.01)" json:"allow_min_qty"`
AllowMaxQty utils.FloatString `xorm:"decimal(40,20) default(999999)" json:"allow_max_qty"`
AllowMinAmount utils.FloatString `xorm:"decimal(40,20) default(0.01)" json:"allow_min_amount"`
AllowMaxAmount utils.FloatString `xorm:"decimal(40,20) default(999999)" json:"allow_max_amount"`
FeeRate utils.FloatString `xorm:"decimal(40,20) default(0)" json:"fee_rate"`
Status status `xorm:"default(0)" json:"status"`
CreateTime utils.Time `xorm:"timestamp created" json:"create_time"`
UpdateTime utils.Time `xorm:"timestamp updated" json:"update_time"`
Target Varieties `xorm:"-" json:"target"`
Base Varieties `xorm:"-" json:"base"`
Id int `xorm:"pk autoincr int" json:"id"`
Symbol string `xorm:"varchar(100) notnull unique(symbol)" json:"symbol"`
Name string `xorm:"varchar(250) notnull" json:"name"`
TargetSymbolId int `xorm:"default(0) unique(symbol_base)" json:"target_symbol_id"` //交易物品
BaseSymbolId int `xorm:"default(0) unique(symbol_base)" json:"base_symbol_id"` //支付货币
PricePrecision int `xorm:"default(2)" json:"price_precision"`
QtyPrecision int `xorm:"default(0)" json:"qty_precision"`
AllowMinQty utils.DeciStr `xorm:"decimal(40,20) default(0.01)" json:"allow_min_qty"`
AllowMaxQty utils.DeciStr `xorm:"decimal(40,20) default(999999)" json:"allow_max_qty"`
AllowMinAmount utils.DeciStr `xorm:"decimal(40,20) default(0.01)" json:"allow_min_amount"`
AllowMaxAmount utils.DeciStr `xorm:"decimal(40,20) default(999999)" json:"allow_max_amount"`
FeeRate utils.DeciStr `xorm:"decimal(40,20) default(0)" json:"fee_rate"`
Status status `xorm:"default(0)" json:"status"`
CreateTime utils.Time `xorm:"timestamp created" json:"create_time"`
UpdateTime utils.Time `xorm:"timestamp updated" json:"update_time"`
Target Varieties `xorm:"-" json:"target"`
Base Varieties `xorm:"-" json:"base"`
}
8 changes: 4 additions & 4 deletions utils/formart_number.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import (
"github.com/shopspring/decimal"
)

type FloatString string
type DeciStr string

func (t FloatString) MarshalJSON() ([]byte, error) {
func (t DeciStr) MarshalJSON() ([]byte, error) {
tt, _ := decimal.NewFromString(string(t))
s := fmt.Sprintf("\"%s\"", tt.String())
return []byte(s), nil
}

func (t FloatString) String() string {
func (t DeciStr) String() string {
return string(t)
}

func (t FloatString) Decimal() decimal.Decimal {
func (t DeciStr) Decimal() decimal.Decimal {
tt, _ := decimal.NewFromString(string(t))
return tt
}
Expand Down

0 comments on commit ca576ae

Please sign in to comment.