feat: add pkg/training/ with types, structs, and repository interfaces
This commit is contained in:
parent
afe0f18523
commit
00158e89fe
9 changed files with 113 additions and 0 deletions
17
pkg/training/attendee.go
Normal file
17
pkg/training/attendee.go
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type AttendeeID uuid.UUID
|
||||||
|
|
||||||
|
type Attendee struct {
|
||||||
|
ID AttendeeID
|
||||||
|
DateID DateID
|
||||||
|
Name string
|
||||||
|
Email string
|
||||||
|
Company string
|
||||||
|
Role string
|
||||||
|
IsStudent bool
|
||||||
|
HasAttended bool
|
||||||
|
HasPaid bool
|
||||||
|
}
|
||||||
13
pkg/training/attendee_repository.go
Normal file
13
pkg/training/attendee_repository.go
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
type AttendeeRepository interface {
|
||||||
|
Find(AttendeeID) (*Attendee, error)
|
||||||
|
FindAll() ([]Attendee, error)
|
||||||
|
FindAllForDate(DateID) ([]Attendee, error)
|
||||||
|
CountForDate(DateID) (int, error)
|
||||||
|
Save(*Attendee) error
|
||||||
|
Update(*Attendee) error
|
||||||
|
UpdateAttendance(AttendeeID, bool) error
|
||||||
|
UpdatePayment(AttendeeID, bool) error
|
||||||
|
Delete(AttendeeID) error
|
||||||
|
}
|
||||||
22
pkg/training/date.go
Normal file
22
pkg/training/date.go
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DateID uuid.UUID
|
||||||
|
|
||||||
|
type Date struct {
|
||||||
|
ID DateID
|
||||||
|
TrainingID ID
|
||||||
|
Date time.Time
|
||||||
|
StartTime time.Time
|
||||||
|
Days int8
|
||||||
|
Price Price
|
||||||
|
IsOnline bool
|
||||||
|
Location string // could be empty (null) for example: Prague, Brno, London, ...
|
||||||
|
Address string // could be empty (null)
|
||||||
|
Capacity int8
|
||||||
|
}
|
||||||
11
pkg/training/date_repository.go
Normal file
11
pkg/training/date_repository.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
type DateRepository interface {
|
||||||
|
Get(DateID) (*Date, error)
|
||||||
|
FindAll() ([]Date, error)
|
||||||
|
FindAllForTraining(ID) ([]Date, error)
|
||||||
|
Save(*Date) error
|
||||||
|
Update(*Date) error
|
||||||
|
Delete(DateID) error
|
||||||
|
IsFull(DateID) (bool, error)
|
||||||
|
}
|
||||||
14
pkg/training/feedback.go
Normal file
14
pkg/training/feedback.go
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
import "github.com/google/uuid"
|
||||||
|
|
||||||
|
type FeedbackID uuid.UUID
|
||||||
|
|
||||||
|
type Feedback struct {
|
||||||
|
ID FeedbackID
|
||||||
|
AttendeeID AttendeeID
|
||||||
|
Rating int
|
||||||
|
Comment string
|
||||||
|
IsAnonymous bool
|
||||||
|
IsSharingAllowed bool
|
||||||
|
}
|
||||||
9
pkg/training/feedback_repository.go
Normal file
9
pkg/training/feedback_repository.go
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
type FeedbackRepository interface {
|
||||||
|
Get(FeedbackID) (*Feedback, error)
|
||||||
|
FindAll() ([]Feedback, error)
|
||||||
|
Save(*Feedback) error
|
||||||
|
Update(*Feedback) error
|
||||||
|
Delete(FeedbackID) error
|
||||||
|
}
|
||||||
3
pkg/training/price.go
Normal file
3
pkg/training/price.go
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
type Price float32
|
||||||
9
pkg/training/repository.go
Normal file
9
pkg/training/repository.go
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
type Repository interface {
|
||||||
|
Save(*Training) error
|
||||||
|
Get(ID) (*Training, error)
|
||||||
|
Update(*Training) error
|
||||||
|
Delete(ID) error
|
||||||
|
FindAll() ([]Training, error)
|
||||||
|
}
|
||||||
15
pkg/training/training.go
Normal file
15
pkg/training/training.go
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
package training
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ID uuid.UUID
|
||||||
|
|
||||||
|
type Training struct {
|
||||||
|
ID ID
|
||||||
|
Days int8
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
Price Price
|
||||||
|
}
|
||||||
Reference in a new issue