module update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package common
|
||||
package dto
|
||||
|
||||
type ErrorResponseDTO struct {
|
||||
Error string `json:"error"`
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package common
|
||||
package dto
|
||||
|
||||
type HealthResponseDTO struct {
|
||||
Status string `json:"status"`
|
||||
|
||||
42
common/vo/currency.go
Normal file
42
common/vo/currency.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package vo
|
||||
|
||||
import "strings"
|
||||
|
||||
type Currency struct {
|
||||
Code string
|
||||
NumericCode string
|
||||
Fraction int
|
||||
Grapheme string
|
||||
Template string
|
||||
Decimal string
|
||||
Thousand string
|
||||
}
|
||||
|
||||
type Currencies map[string]*Currency
|
||||
|
||||
var currencies = Currencies{
|
||||
"EUR": {Decimal: ".", Thousand: ",", Code: "EUR", Fraction: 2, NumericCode: "978", Grapheme: "\u20ac", Template: "$1"},
|
||||
"GBP": {Decimal: ".", Thousand: ",", Code: "GBP", Fraction: 2, NumericCode: "826", Grapheme: "\u00a3", Template: "$1"},
|
||||
"PLN": {Decimal: ".", Thousand: ",", Code: "PLN", Fraction: 2, NumericCode: "985", Grapheme: "z\u0142", Template: "1 $"},
|
||||
"USD": {Decimal: ".", Thousand: ",", Code: "USD", Fraction: 2, NumericCode: "840", Grapheme: "$", Template: "$1"},
|
||||
}
|
||||
|
||||
func NewCurrency(code string) *Currency {
|
||||
return &Currency{Code: strings.ToUpper(code)}
|
||||
}
|
||||
|
||||
func (c *Currency) Default() *Currency {
|
||||
return &Currency{Decimal: ".", Thousand: ",", Code: c.Code, Fraction: 2, Grapheme: c.Code, Template: "1$"}
|
||||
}
|
||||
|
||||
func (c *Currency) Get() *Currency {
|
||||
if curr, ok := currencies[c.Code]; ok {
|
||||
return curr
|
||||
}
|
||||
|
||||
return c.getDefault()
|
||||
}
|
||||
|
||||
func (c *Currency) Equals(oc *Currency) bool {
|
||||
return c.Code == oc.Code
|
||||
}
|
||||
4
common/vo/money.go
Normal file
4
common/vo/money.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package vo
|
||||
|
||||
type Money struct {
|
||||
}
|
||||
Reference in New Issue
Block a user