1
0
Fork 0

feat: add basic app

This commit is contained in:
Vojtěch Mareš 2024-10-10 21:29:08 +02:00
parent d4c1af4831
commit c94098afef
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D
13 changed files with 1850 additions and 0 deletions

View file

@ -0,0 +1,76 @@
package training
import (
"github.com/shopspring/decimal"
"gitlab.mareshq.com/hq/backoffice/backoffice-api/internal/currency"
)
type ID = int
type Training struct {
id ID // unique and auto-incrementing
published bool
retired bool
days int8
// In the future, this should be localized
name string
pricing []Price `db:"-"`
}
type Price struct {
Amount decimal.Decimal
Currency currency.Currency
Type PriceType
}
type PriceType string
const (
OpenTrainingPriceType PriceType = "OPEN"
CorporateTrainingPriceType PriceType = "CORPORATE"
)
func NewTraining(name string, days int8, pricing []Price) *Training {
t := &Training{
// metadata
published: false,
retired: false,
// data
name: name,
days: days,
pricing: make([]Price, 0),
}
if pricing != nil {
t.pricing = pricing
}
return t
}
func (t *Training) ID() ID {
return t.id
}
func (t *Training) Days() int8 {
return t.days
}
func (t *Training) Published() bool {
return t.published
}
func (t *Training) Retired() bool {
return t.retired
}
func (t *Training) Name() string {
return t.name
}
func (t *Training) Pricing() []Price {
return t.pricing
}