Documentation ¶
Index ¶
- Variables
- type Day
- type Duration
- type List
- type ListDayOptions
- type ListDaysOption
- type ListSettings
- type Moment
- type MomentType
- func (t MomentType) MarshalJSON() ([]byte, error)
- func (t *MomentType) ReadStr(str string) error
- func (t *MomentType) Scan(src interface{}) error
- func (t MomentType) StrErr() (string, error)
- func (t MomentType) String() string
- func (t *MomentType) UnmarshalJSON(bytes []byte) error
- func (t MomentType) Value() (driver.Value, error)
- type Repository
- type Service
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAlreadyStarted = errors.New("already started") ErrNotStartedYet = errors.New("not started yet") ErrNotEndedYet = errors.New("not ended yet") ErrConflict = errors.New("conflict") )
View Source
var ErrInvalidDuration = errors.New("invalid duration")
View Source
var ErrInvalidMomentType = errors.New("invalid moment type")
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
This section is empty.
Types ¶
type List ¶
type List struct { ID int `json:"id"` Name string `json:"name"` Settings *ListSettings `json:"settings,omitempty"` }
type ListDayOptions ¶
type ListDayOptions struct { }
type ListDaysOption ¶
type ListDaysOption func(*ListDayOptions)
type ListSettings ¶
type ListSettings struct {
DailyTime *Duration `json:"daily_time,omitempty"`
}
type Moment ¶
type Moment struct { Type MomentType `json:"type"` Time time.Time `json:"time"` }
type MomentType ¶
type MomentType int
const ( MomentTypeStart MomentType = iota MomentTypeStartBreak MomentTypeEndBreak MomentTypeEnd )
func (MomentType) MarshalJSON ¶
func (t MomentType) MarshalJSON() ([]byte, error)
func (*MomentType) ReadStr ¶
func (t *MomentType) ReadStr(str string) error
func (*MomentType) Scan ¶
func (t *MomentType) Scan(src interface{}) error
func (MomentType) StrErr ¶
func (t MomentType) StrErr() (string, error)
func (MomentType) String ¶
func (t MomentType) String() string
TODO: add validation for MomentType enum
func (*MomentType) UnmarshalJSON ¶
func (t *MomentType) UnmarshalJSON(bytes []byte) error
type Repository ¶
type Repository interface { AddList(ctx context.Context, list List) (int, error) GetLists(ctx context.Context) ([]List, error) GetListByID(ctx context.Context, listID int) (*List, error) UpdateList(ctx context.Context, list List) error DeleteListByID(ctx context.Context, listID int) error AddDay(ctx context.Context, listID int, day Day) error GetDays(ctx context.Context, listID int) ([]Day, error) GetDayByDate(ctx context.Context, listID int, date time.Time) (*Day, error) UpdateDay(ctx context.Context, listID int, day Day) error DeleteDayByDate(ctx context.Context, listID int, date time.Time) error }
func NewRepository ¶
func NewRepository(db *sqlx.DB, logger log.Logger) Repository
type Service ¶
type Service interface { // lists AddList(ctx context.Context, name string, settings *ListSettings) (*List, error) GetLists(ctx context.Context) ([]List, error) GetList(ctx context.Context, listID int) (*List, error) UpdateList(ctx context.Context, listID int, name string, settings *ListSettings) (*List, error) DeleteList(ctx context.Context, listID int) error // days AddDay(ctx context.Context, listID int, date time.Time, moments []Moment) (*Day, error) GetDays(ctx context.Context, listID int, opts ...ListDaysOption) ([]Day, error) GetDay(ctx context.Context, listID int, date time.Time) (*Day, error) UpdateDay(ctx context.Context, listID int, date time.Time, moments []Moment) (*Day, error) DeleteDay(ctx context.Context, listID int, date time.Time) error // dynamic utility functions StartDay(ctx context.Context, listID int, timeStamp time.Time) error StartBreak(ctx context.Context, listID int, timeStamp time.Time) error EndBreak(ctx context.Context, listID int, timeStamp time.Time) error EndDay(ctx context.Context, listID int, timeStamp time.Time) error }
func NewService ¶
func NewService(repository Repository, logger log.Logger) Service
Click to show internal directories.
Click to hide internal directories.