1
0
Fork 0
This repository has been archived on 2025-08-23. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mareshq-backoffice-v3-api/internal/training/model.go

76 lines
1.2 KiB
Go

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
}