feat(training): add pricing and TrainingPrice with amount, currency and type (open|corporate)
This commit is contained in:
parent
db6ff45c99
commit
5d83bb0308
8 changed files with 316 additions and 45 deletions
|
|
@ -2,6 +2,8 @@ package training
|
|||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/shopspring/decimal"
|
||||
"gitlab.mareshq.com/hq/yggdrasil/internal/currency"
|
||||
)
|
||||
|
||||
type TrainingID = uuid.UUID
|
||||
|
|
@ -15,4 +17,18 @@ type Training struct {
|
|||
Name string
|
||||
Days int8
|
||||
Description string
|
||||
Pricing []TrainingPrice
|
||||
}
|
||||
|
||||
type TrainingPrice struct {
|
||||
Amount decimal.Decimal
|
||||
Currency currency.Currency
|
||||
Type TrainingPriceType
|
||||
}
|
||||
|
||||
type TrainingPriceType string
|
||||
|
||||
const (
|
||||
OpenTrainingPrice TrainingPriceType = "OPEN"
|
||||
CorporateTrainingPrice TrainingPriceType = "CORPORATE"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package training
|
||||
|
||||
import (
|
||||
"github.com/shopspring/decimal"
|
||||
"gitlab.mareshq.com/hq/yggdrasil/internal/currency"
|
||||
)
|
||||
|
||||
type TrainingRepository interface {
|
||||
Create(training *Training) error
|
||||
FindByID(id TrainingID) (*Training, error)
|
||||
|
|
@ -17,35 +22,167 @@ func NewInMemoryTrainingRepository() *InMemoryTrainingRepository {
|
|||
trainings: make(map[TrainingID]Training),
|
||||
}
|
||||
|
||||
repo.Create(&Training{
|
||||
_ = repo.Create(&Training{
|
||||
Name: "Kubernetes",
|
||||
Days: 2,
|
||||
Description: "",
|
||||
Description: "Kubernetes",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(450),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(2000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(9900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(49000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
repo.Create(&Training{
|
||||
_ = repo.Create(&Training{
|
||||
Name: "Terraform",
|
||||
Days: 1,
|
||||
Description: "",
|
||||
Description: "Terraform",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(1000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(4900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(24000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
repo.Create(&Training{
|
||||
_ = repo.Create(&Training{
|
||||
Name: "RKE2",
|
||||
Days: 1,
|
||||
Description: "",
|
||||
Description: "RKE2",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(1000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(4900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(24000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
repo.Create(&Training{
|
||||
_ = repo.Create(&Training{
|
||||
Name: "GitHub Actions",
|
||||
Days: 1,
|
||||
Description: "",
|
||||
Description: "GitHub Actions",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(1000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(4900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(24000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
repo.Create(&Training{
|
||||
_ = repo.Create(&Training{
|
||||
Name: "GitLab CI",
|
||||
Days: 1,
|
||||
Description: "",
|
||||
Description: "GitLab CI",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(200),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(1000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(4900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(24000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
repo.Create(&Training{
|
||||
_ = repo.Create(&Training{
|
||||
Name: "Prometheus",
|
||||
Days: 2,
|
||||
Description: "",
|
||||
Description: "Prometheus",
|
||||
Pricing: []TrainingPrice{
|
||||
{
|
||||
Amount: decimal.NewFromInt(450),
|
||||
Currency: currency.USD,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(2000),
|
||||
Currency: currency.USD,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(9900),
|
||||
Currency: currency.CZK,
|
||||
Type: OpenTrainingPrice,
|
||||
},
|
||||
{
|
||||
Amount: decimal.NewFromInt(49000),
|
||||
Currency: currency.CZK,
|
||||
Type: CorporateTrainingPrice,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
return repo
|
||||
|
|
|
|||
Reference in a new issue