1
0
Fork 0

refactor: move currency to money package and add new type Price, refactor api and use price there too

This commit is contained in:
Vojtěch Mareš 2024-05-05 18:19:56 +02:00
parent 18d1c98b76
commit ef1526a1ac
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
7 changed files with 127 additions and 137 deletions

View file

@ -350,31 +350,16 @@ components:
path: gitlab.mareshq.com/hq/yggdrasil/pkg/training path: gitlab.mareshq.com/hq/yggdrasil/pkg/training
TrainingPrice: TrainingPrice:
type: object allOf:
- $ref: "#/components/schemas/Price"
- type: object
properties: properties:
currency:
type: string
enum:
- CZK
- EUR
- USD
x-go-type: currency.Currency
x-go-type-package:
path: gitlab.mareshq.com/hq/yggdrasil/internal/currency
amount:
type: number
minimum: 0
x-go-type: decimal.Decimal
x-go-type-package:
path: github.com/shopspring/decimal
type: type:
type: string type: string
enum: enum:
- OPEN - OPEN
- CORPORATE - CORPORATE
required: required:
- currency
- amount
- type - type
CreateTrainingDateRequest: CreateTrainingDateRequest:
@ -443,7 +428,7 @@ components:
format: int8 format: int8
minimum: 1 minimum: 1
price: price:
$ref: "#/components/schemas/TrainingDatePrice" $ref: "#/components/schemas/Price"
required: required:
- trainingID - trainingID
- date - date
@ -465,7 +450,14 @@ components:
required: required:
- id - id
TrainingDatePrice: TrainingDateID:
type: string
format: uuid
x-go-type: training.TrainingDateID
x-go-type-import:
path: gitlab.mareshq.com/hq/yggdrasil/pkg/training
Price:
type: object type: object
properties: properties:
currency: currency:
@ -474,9 +466,9 @@ components:
- CZK - CZK
- EUR - EUR
- USD - USD
x-go-type: currency.Currency x-go-type: money.Currency
x-go-type-package: x-go-type-package:
path: gitlab.mareshq.com/hq/yggdrasil/internal/currency path: gitlab.mareshq.com/hq/yggdrasil/internal/money
amount: amount:
type: number type: number
minimum: 0 minimum: 0
@ -487,13 +479,6 @@ components:
- currency - currency
- amount - amount
TrainingDateID:
type: string
format: uuid
x-go-type: training.TrainingDateID
x-go-type-import:
path: gitlab.mareshq.com/hq/yggdrasil/pkg/training
ProblemDetails: ProblemDetails:
type: object type: object
description: > description: >

View file

@ -5,7 +5,7 @@ import (
"time" "time"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"gitlab.mareshq.com/hq/yggdrasil/internal/currency" "gitlab.mareshq.com/hq/yggdrasil/internal/money"
"gitlab.mareshq.com/hq/yggdrasil/pkg/training" "gitlab.mareshq.com/hq/yggdrasil/pkg/training"
) )
@ -30,22 +30,22 @@ func (f *Faker) GenerateFakeData() error {
Pricing: []training.TrainingPrice{ Pricing: []training.TrainingPrice{
{ {
Amount: decimal.NewFromInt(450), Amount: decimal.NewFromInt(450),
Currency: currency.USD, Currency: money.USD,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(2000), Amount: decimal.NewFromInt(2000),
Currency: currency.USD, Currency: money.USD,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(9900), Amount: decimal.NewFromInt(9900),
Currency: currency.CZK, Currency: money.CZK,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(49000), Amount: decimal.NewFromInt(49000),
Currency: currency.CZK, Currency: money.CZK,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
}, },
@ -57,22 +57,22 @@ func (f *Faker) GenerateFakeData() error {
Pricing: []training.TrainingPrice{ Pricing: []training.TrainingPrice{
{ {
Amount: decimal.NewFromInt(200), Amount: decimal.NewFromInt(200),
Currency: currency.USD, Currency: money.USD,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(1000), Amount: decimal.NewFromInt(1000),
Currency: currency.USD, Currency: money.USD,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(4900), Amount: decimal.NewFromInt(4900),
Currency: currency.CZK, Currency: money.CZK,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(24000), Amount: decimal.NewFromInt(24000),
Currency: currency.CZK, Currency: money.CZK,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
}, },
@ -84,22 +84,22 @@ func (f *Faker) GenerateFakeData() error {
Pricing: []training.TrainingPrice{ Pricing: []training.TrainingPrice{
{ {
Amount: decimal.NewFromInt(200), Amount: decimal.NewFromInt(200),
Currency: currency.USD, Currency: money.USD,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(1000), Amount: decimal.NewFromInt(1000),
Currency: currency.USD, Currency: money.USD,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(4900), Amount: decimal.NewFromInt(4900),
Currency: currency.CZK, Currency: money.CZK,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(24000), Amount: decimal.NewFromInt(24000),
Currency: currency.CZK, Currency: money.CZK,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
}, },
@ -111,22 +111,22 @@ func (f *Faker) GenerateFakeData() error {
Pricing: []training.TrainingPrice{ Pricing: []training.TrainingPrice{
{ {
Amount: decimal.NewFromInt(200), Amount: decimal.NewFromInt(200),
Currency: currency.USD, Currency: money.USD,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(1000), Amount: decimal.NewFromInt(1000),
Currency: currency.USD, Currency: money.USD,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(4900), Amount: decimal.NewFromInt(4900),
Currency: currency.CZK, Currency: money.CZK,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(24000), Amount: decimal.NewFromInt(24000),
Currency: currency.CZK, Currency: money.CZK,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
}, },
@ -138,22 +138,22 @@ func (f *Faker) GenerateFakeData() error {
Pricing: []training.TrainingPrice{ Pricing: []training.TrainingPrice{
{ {
Amount: decimal.NewFromInt(200), Amount: decimal.NewFromInt(200),
Currency: currency.USD, Currency: money.USD,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(1000), Amount: decimal.NewFromInt(1000),
Currency: currency.USD, Currency: money.USD,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(4900), Amount: decimal.NewFromInt(4900),
Currency: currency.CZK, Currency: money.CZK,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(24000), Amount: decimal.NewFromInt(24000),
Currency: currency.CZK, Currency: money.CZK,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
}, },
@ -165,22 +165,22 @@ func (f *Faker) GenerateFakeData() error {
Pricing: []training.TrainingPrice{ Pricing: []training.TrainingPrice{
{ {
Amount: decimal.NewFromInt(450), Amount: decimal.NewFromInt(450),
Currency: currency.USD, Currency: money.USD,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(2000), Amount: decimal.NewFromInt(2000),
Currency: currency.USD, Currency: money.USD,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(9900), Amount: decimal.NewFromInt(9900),
Currency: currency.CZK, Currency: money.CZK,
Type: training.OpenTrainingPrice, Type: training.OpenTrainingPrice,
}, },
{ {
Amount: decimal.NewFromInt(49000), Amount: decimal.NewFromInt(49000),
Currency: currency.CZK, Currency: money.CZK,
Type: training.CorporateTrainingPrice, Type: training.CorporateTrainingPrice,
}, },
}, },
@ -219,9 +219,9 @@ func (f *Faker) GenerateFakeData() error {
amount = decimal.NewFromInt(9900) amount = decimal.NewFromInt(9900)
} }
cur := currency.CZK cur := money.CZK
if online { if online {
cur = currency.EUR cur = money.EUR
if t.Days == 2 { if t.Days == 2 {
amount = decimal.NewFromInt(450) amount = decimal.NewFromInt(450)
@ -238,7 +238,7 @@ func (f *Faker) GenerateFakeData() error {
Location: location, Location: location,
Address: "TBD", Address: "TBD",
Capacity: 12, Capacity: 12,
Price: training.TrainingDatePrice{ Price: money.Price{
Amount: amount, Amount: amount,
Currency: cur, Currency: cur,
}, },

View file

@ -1,4 +1,4 @@
package currency package money
type Currency string type Currency string

8
internal/money/price.go Normal file
View file

@ -0,0 +1,8 @@
package money
import "github.com/shopspring/decimal"
type Price struct {
Amount decimal.Decimal
Currency Currency
}

View file

@ -18,7 +18,7 @@ import (
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/oapi-codegen/runtime" "github.com/oapi-codegen/runtime"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"gitlab.mareshq.com/hq/yggdrasil/internal/currency" "gitlab.mareshq.com/hq/yggdrasil/internal/money"
"gitlab.mareshq.com/hq/yggdrasil/pkg/training" "gitlab.mareshq.com/hq/yggdrasil/pkg/training"
) )
@ -77,10 +77,16 @@ type NewTrainingDate struct {
Days int8 `json:"days"` Days int8 `json:"days"`
IsOnline bool `json:"isOnline"` IsOnline bool `json:"isOnline"`
Location string `json:"location"` Location string `json:"location"`
Price TrainingDatePrice `json:"price"` Price Price `json:"price"`
StartTime string `json:"startTime"` StartTime string `json:"startTime"`
} }
// Price defines model for Price.
type Price struct {
Amount decimal.Decimal `json:"amount"`
Currency money.Currency `json:"currency"`
}
// ProblemDetails Schema that carries the details of an error in an HTTP response. See https://datatracker.ietf.org/doc/html/rfc7807 for more information. // ProblemDetails Schema that carries the details of an error in an HTTP response. See https://datatracker.ietf.org/doc/html/rfc7807 for more information.
type ProblemDetails struct { type ProblemDetails struct {
// Detail A human-readable explanation specific to this occurrence of the problem. // Detail A human-readable explanation specific to this occurrence of the problem.
@ -117,26 +123,20 @@ type TrainingDate struct {
Id TrainingDateID `json:"id"` Id TrainingDateID `json:"id"`
IsOnline bool `json:"isOnline"` IsOnline bool `json:"isOnline"`
Location string `json:"location"` Location string `json:"location"`
Price TrainingDatePrice `json:"price"` Price Price `json:"price"`
StartTime string `json:"startTime"` StartTime string `json:"startTime"`
} }
// TrainingDateID defines model for TrainingDateID. // TrainingDateID defines model for TrainingDateID.
type TrainingDateID = training.TrainingDateID type TrainingDateID = training.TrainingDateID
// TrainingDatePrice defines model for TrainingDatePrice.
type TrainingDatePrice struct {
Amount decimal.Decimal `json:"amount"`
Currency currency.Currency `json:"currency"`
}
// TrainingID defines model for TrainingID. // TrainingID defines model for TrainingID.
type TrainingID = training.TrainingID type TrainingID = training.TrainingID
// TrainingPrice defines model for TrainingPrice. // TrainingPrice defines model for TrainingPrice.
type TrainingPrice struct { type TrainingPrice struct {
Amount decimal.Decimal `json:"amount"` Amount decimal.Decimal `json:"amount"`
Currency currency.Currency `json:"currency"` Currency money.Currency `json:"currency"`
Type TrainingPriceType `json:"type"` Type TrainingPriceType `json:"type"`
} }
@ -1344,37 +1344,37 @@ func (sh *strictHandler) ListTrainingUpcomingDates(ctx *fiber.Ctx, trainingID Tr
// Base64 encoded, gzipped, json marshaled Swagger object // Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{ var swaggerSpec = []string{
"H4sIAAAAAAAC/+xaX3PbuBH/Khi0b6VFpZebu9FT3Si90zSNVcfuQ9M8QORKREICNLC0o/Hok/Sp36X9", "H4sIAAAAAAAC/+xazXLjuBF+FRSSW2hRk52t3dIpzmiyq8rEdjx2DnF8gMiWCA8J0EDTHpVLT5JT3iV5",
"Xh0AJEVSlEhZ0li+8ZNlkNj97f/Fgo80kEkqBQjUdPRIU6ZYAgjK/nejGBdcLMYMYTI2KyHoQPEUuRR0", "rxQAkiIpSqQsqywnPlnmT+Pr/voPDT7RQCapFCBQ09ETTZliCSAo+9+VYl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COzZqx1jF2bBbY",
"trNQ/kmava7IPLuU3mj+ehi3Rwf4XPY9dd+4dwEYnhRI3wLw22oiO110d+HYY9TS+pndi2gt2z8MfDEt", "fm3bURj/IM1eV2QeXUpvNH89yO3RAb4Wv4fuG3cuAMODAulbAP63mshOF91eOHYYtbR+L/YmWsv2L9ze",
"ZstApnOkZqjYL2WcURpiyoDFJIR7iGWagMD8q5ra2Hzk+7F5L5IaRz8Mh0Nrr5xZk+JV4S2asJnMsDYu", "TIvZMpDpHKkZKfZ7BEdKQ00ZsJiE8ACxTBMQmH+7UBubj3w/Ns9FUuPoh+FwaPnKF2tKPC+8RRM2lRnW",
"yifra3yrL6v/BwAA//8Lqnf6hDQAAA==", "xkX5ZH2Fb3m7/G8AAAD//6DZ/Q5BMwAA",
} }
// GetSwagger returns the content of the embedded swagger specification file // GetSwagger returns the content of the embedded swagger specification file

View file

@ -5,6 +5,7 @@ import (
"time" "time"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"gitlab.mareshq.com/hq/yggdrasil/internal/money"
"gitlab.mareshq.com/hq/yggdrasil/pkg/training" "gitlab.mareshq.com/hq/yggdrasil/pkg/training"
) )
@ -211,7 +212,7 @@ func (h *APIHandlers) ListTrainingDates(ctx context.Context, req ListTrainingDat
Location: td.Location, Location: td.Location,
Address: td.Address, Address: td.Address,
Capacity: td.Capacity, Capacity: td.Capacity,
Price: TrainingDatePrice{ Price: Price{
Amount: td.Price.Amount, Amount: td.Price.Amount,
Currency: td.Price.Currency, Currency: td.Price.Currency,
}, },
@ -222,7 +223,7 @@ func (h *APIHandlers) ListTrainingDates(ctx context.Context, req ListTrainingDat
} }
func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTrainingDateRequestObject) (CreateTrainingDateResponseObject, error) { func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTrainingDateRequestObject) (CreateTrainingDateResponseObject, error) {
price := training.TrainingDatePrice{ price := money.Price{
Amount: req.Body.Price.Amount, Amount: req.Body.Price.Amount,
Currency: req.Body.Price.Currency, Currency: req.Body.Price.Currency,
} }
@ -267,7 +268,7 @@ func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTraining
Location: td.Location, Location: td.Location,
Address: td.Address, Address: td.Address,
Capacity: td.Capacity, Capacity: td.Capacity,
Price: TrainingDatePrice{ Price: Price{
Amount: td.Price.Amount, Amount: td.Price.Amount,
Currency: td.Price.Currency, Currency: td.Price.Currency,
}, },
@ -320,7 +321,7 @@ func (h *APIHandlers) GetTrainingDate(ctx context.Context, req GetTrainingDateRe
Location: td.Location, Location: td.Location,
Address: td.Address, Address: td.Address,
Capacity: td.Capacity, Capacity: td.Capacity,
Price: TrainingDatePrice{ Price: Price{
Amount: td.Price.Amount, Amount: td.Price.Amount,
Currency: td.Price.Currency, Currency: td.Price.Currency,
}, },
@ -328,7 +329,7 @@ func (h *APIHandlers) GetTrainingDate(ctx context.Context, req GetTrainingDateRe
} }
func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTrainingDateRequestObject) (UpdateTrainingDateResponseObject, error) { func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTrainingDateRequestObject) (UpdateTrainingDateResponseObject, error) {
price := training.TrainingDatePrice{ price := money.Price{
Amount: req.Body.Price.Amount, Amount: req.Body.Price.Amount,
Currency: req.Body.Price.Currency, Currency: req.Body.Price.Currency,
} }
@ -374,7 +375,7 @@ func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTraining
Location: td.Location, Location: td.Location,
Address: td.Address, Address: td.Address,
Capacity: td.Capacity, Capacity: td.Capacity,
Price: TrainingDatePrice{ Price: Price{
Amount: td.Price.Amount, Amount: td.Price.Amount,
Currency: td.Price.Currency, Currency: td.Price.Currency,
}, },
@ -416,7 +417,7 @@ func (h *APIHandlers) ListAllUpcomingTrainingDates(ctx context.Context, req List
Location: td.Location, Location: td.Location,
Address: td.Address, Address: td.Address,
Capacity: td.Capacity, Capacity: td.Capacity,
Price: TrainingDatePrice{ Price: Price{
Amount: td.Price.Amount, Amount: td.Price.Amount,
Currency: td.Price.Currency, Currency: td.Price.Currency,
}, },
@ -449,7 +450,7 @@ func (h *APIHandlers) ListTrainingUpcomingDates(ctx context.Context, req ListTra
Location: td.Location, Location: td.Location,
Address: td.Address, Address: td.Address,
Capacity: td.Capacity, Capacity: td.Capacity,
Price: TrainingDatePrice{ Price: Price{
Amount: td.Price.Amount, Amount: td.Price.Amount,
Currency: td.Price.Currency, Currency: td.Price.Currency,
}, },

View file

@ -5,7 +5,7 @@ import (
"github.com/google/uuid" "github.com/google/uuid"
"github.com/shopspring/decimal" "github.com/shopspring/decimal"
"gitlab.mareshq.com/hq/yggdrasil/internal/currency" "gitlab.mareshq.com/hq/yggdrasil/internal/money"
) )
type TrainingID = uuid.UUID type TrainingID = uuid.UUID
@ -24,7 +24,7 @@ type Training struct {
type TrainingPrice struct { type TrainingPrice struct {
Amount decimal.Decimal Amount decimal.Decimal
Currency currency.Currency Currency money.Currency
Type TrainingPriceType Type TrainingPriceType
} }
@ -52,10 +52,6 @@ type TrainingDate struct {
Location string Location string
Address string Address string
Capacity int8 Capacity int8
Price TrainingDatePrice Price money.Price
} }
type TrainingDatePrice struct {
Amount decimal.Decimal
Currency currency.Currency
}