module update

This commit is contained in:
Piotr Biernat
2024-12-06 16:14:44 +01:00
parent 1f4b619e89
commit 2cf4d4c25d
8 changed files with 54 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
package common
package dto
type ErrorResponseDTO struct {
Error string `json:"error"`

View File

@@ -1,4 +1,4 @@
package common
package dto
type HealthResponseDTO struct {
Status string `json:"status"`

42
common/vo/currency.go Normal file
View 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
View File

@@ -0,0 +1,4 @@
package vo
type Money struct {
}