domain

package
v0.0.0-...-3784b31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Calendar

type Calendar struct {
	Title string
	// contains filtered or unexported fields
}

Calendar Calendar struct

func NewCalendar

func NewCalendar(title string, s StorageInterface) *Calendar

NewCalendar Init new calendar

func (*Calendar) CreateEvent

func (c *Calendar) CreateEvent(title string, from, to time.Time) (*Event, error)

CreateEvent Create new event and save it to storage

func (*Calendar) GetEventByID

func (c *Calendar) GetEventByID(id string) (*Event, error)

GetEventByID Return event by ID

func (*Calendar) GetEvents

func (c *Calendar) GetEvents() ([]*Event, error)

GetEvents Return list of all events

func (*Calendar) RemoveEvent

func (c *Calendar) RemoveEvent(event *Event) error

RemoveEvent Remove existing event

func (*Calendar) UpdateEvent

func (c *Calendar) UpdateEvent(event *Event) error

UpdateEvent Update existing event

type CalendarInterface

type CalendarInterface interface {
	GetEvents() ([]*Event, error)
	GetEventByID(id string) (*Event, error)
	AddEvent(title string, from, to *time.Time) (*Event, error)
	UpdateEvent(event *Event) error
	RemoveEvent(event *Event) error
}

CalendarInterface Interface of calendar

type Event

type Event struct {
	ID       uuid.UUID
	Title    string
	DateFrom time.Time
	DateTo   time.Time
}

Event Event struct

func NewEvent

func NewEvent(title string, from, to time.Time) *Event

NewEvent Return new event instance

type Storage

type Storage struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Storage Storage struct

func NewStorage

func NewStorage() *Storage

NewStorage Create new storage

func (*Storage) GetAll

func (storage *Storage) GetAll() ([]*Event, error)

GetAll Return list of all events

func (*Storage) GetByID

func (storage *Storage) GetByID(id string) (*Event, error)

GetByID Return event by ID

func (*Storage) GetByPeriod

func (storage *Storage) GetByPeriod(from, to time.Time) ([]*Event, error)

GetByPeriod Return list of events by period

func (*Storage) Remove

func (storage *Storage) Remove(event *Event) error

Remove Remove event from storage

func (*Storage) Save

func (storage *Storage) Save(event *Event) error

Save Create or update event in storage

type StorageInterface

type StorageInterface interface {
	GetAll() ([]*Event, error)
	GetByID(id string) (*Event, error)
	GetByPeriod(from, to time.Time) ([]*Event, error)
	Save(event *Event) error
	Remove(event *Event) error
}

StorageInterface Interface of events storage

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL