refactor: move currency to money package and add new type Price, refactor api and use price there too
This commit is contained in:
parent
18d1c98b76
commit
ef1526a1ac
7 changed files with 127 additions and 137 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"gitlab.mareshq.com/hq/yggdrasil/internal/money"
|
||||
"gitlab.mareshq.com/hq/yggdrasil/pkg/training"
|
||||
)
|
||||
|
||||
|
|
@ -211,7 +212,7 @@ func (h *APIHandlers) ListTrainingDates(ctx context.Context, req ListTrainingDat
|
|||
Location: td.Location,
|
||||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: TrainingDatePrice{
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount,
|
||||
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) {
|
||||
price := training.TrainingDatePrice{
|
||||
price := money.Price{
|
||||
Amount: req.Body.Price.Amount,
|
||||
Currency: req.Body.Price.Currency,
|
||||
}
|
||||
|
|
@ -267,7 +268,7 @@ func (h *APIHandlers) CreateTrainingDate(ctx context.Context, req CreateTraining
|
|||
Location: td.Location,
|
||||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: TrainingDatePrice{
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
|
|
@ -320,7 +321,7 @@ func (h *APIHandlers) GetTrainingDate(ctx context.Context, req GetTrainingDateRe
|
|||
Location: td.Location,
|
||||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: TrainingDatePrice{
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount,
|
||||
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) {
|
||||
price := training.TrainingDatePrice{
|
||||
price := money.Price{
|
||||
Amount: req.Body.Price.Amount,
|
||||
Currency: req.Body.Price.Currency,
|
||||
}
|
||||
|
|
@ -374,7 +375,7 @@ func (h *APIHandlers) UpdateTrainingDate(ctx context.Context, req UpdateTraining
|
|||
Location: td.Location,
|
||||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: TrainingDatePrice{
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
|
|
@ -416,7 +417,7 @@ func (h *APIHandlers) ListAllUpcomingTrainingDates(ctx context.Context, req List
|
|||
Location: td.Location,
|
||||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: TrainingDatePrice{
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
|
|
@ -449,7 +450,7 @@ func (h *APIHandlers) ListTrainingUpcomingDates(ctx context.Context, req ListTra
|
|||
Location: td.Location,
|
||||
Address: td.Address,
|
||||
Capacity: td.Capacity,
|
||||
Price: TrainingDatePrice{
|
||||
Price: Price{
|
||||
Amount: td.Price.Amount,
|
||||
Currency: td.Price.Currency,
|
||||
},
|
||||
|
|
|
|||
Reference in a new issue