todo

package
v0.0.0-...-961dd66 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTodoAlreadyDone = errors.New("Todo is already done")
View Source
var ErrTodoNotDone = errors.New("Todo is not done")
View Source
var ErrTodoNotFound = errors.New("Todo was not found")

Functions

This section is empty.

Types

type CommandHandler

type CommandHandler struct {
	// contains filtered or unexported fields
}

func NewCommandHandler

func NewCommandHandler(repo TodoCollection) *CommandHandler

func (*CommandHandler) CreateTodoHandler

func (c *CommandHandler) CreateTodoHandler(ctx context.Context, command CreateTodo) error

func (*CommandHandler) DeleteHandler

func (c *CommandHandler) DeleteHandler(ctx context.Context, command DeleteTodo) error

func (*CommandHandler) DoTodoHandler

func (c *CommandHandler) DoTodoHandler(ctx context.Context, command DoTodo) error

func (*CommandHandler) UndoTodoHandler

func (c *CommandHandler) UndoTodoHandler(ctx context.Context, command UndoTodo) error

func (*CommandHandler) UpdateTodoHandler

func (c *CommandHandler) UpdateTodoHandler(ctx context.Context, command UpdateTodo) error

type CreateTodo

type CreateTodo struct {
	Title       string    `binding:"required"`
	Description string    `binding:"required"`
	Deadline    time.Time `binding:"required"`
}

type DeleteTodo

type DeleteTodo struct {
	TodoID string `json:"todo_id" binding:"required,uuid4"`
}

type DoTodo

type DoTodo struct {
	TodoID string `json:"todo_id" binding:"required,uuid4"`
}

type FindAllTodos

type FindAllTodos struct{}

type FindTodoByID

type FindTodoByID struct {
	TodoID string
}

type QueryHandler

type QueryHandler struct {
	// contains filtered or unexported fields
}

func NewQueryHandler

func NewQueryHandler(finder TodoFinder) *QueryHandler

func (*QueryHandler) FindAllTodosHandler

func (qh *QueryHandler) FindAllTodosHandler(ctx context.Context, _ FindAllTodos) ([]TodoView, error)

func (*QueryHandler) FindTodoByIDHandler

func (qh *QueryHandler) FindTodoByIDHandler(ctx context.Context, query FindTodoByID) (TodoView, error)

type Todo

type Todo struct {
	eventstore.BaseAggregate

	Title       string
	Description string
	Done        bool
	Deleted     bool
	Deadline    time.Time
}

func NewTodo

func NewTodo(title, description string, deadline time.Time) *Todo

func TodoFromHistory

func TodoFromHistory(events eventstore.DomainEventIterator) *Todo

func (*Todo) Delete

func (t *Todo) Delete()

func (*Todo) Do

func (t *Todo) Do() error

func (*Todo) TodoID

func (t *Todo) TodoID() uuid.UUID

func (*Todo) Undo

func (t *Todo) Undo() error

func (*Todo) Update

func (t *Todo) Update(title, description string, deadline time.Time)

func (*Todo) WhenTodoWasCreated

func (t *Todo) WhenTodoWasCreated(e TodoWasCreated, _ map[string]interface{})

func (*Todo) WhenTodoWasDeleted

func (t *Todo) WhenTodoWasDeleted(_ TodoWasDeleted, _ map[string]interface{})

func (*Todo) WhenTodoWasDone

func (t *Todo) WhenTodoWasDone(_ TodoWasDone, _ map[string]interface{})

func (*Todo) WhenTodoWasUndone

func (t *Todo) WhenTodoWasUndone(_ TodoWasUndone, _ map[string]interface{})

func (*Todo) WhenTodoWasUpdated

func (t *Todo) WhenTodoWasUpdated(e TodoWasUpdated, _ map[string]interface{})

type TodoCollection

type TodoCollection interface {
	Get(ctx context.Context, todoID uuid.UUID) (*Todo, error)
	Save(ctx context.Context, todo *Todo) error
}

type TodoFinder

type TodoFinder interface {
	Find(ctx context.Context, todoID string) (TodoView, error)
	FindAll(ctx context.Context) ([]TodoView, error)
}

type TodoView

type TodoView struct {
	ID          string    `json:"id"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Done        bool      `json:"done"`
	Deadline    time.Time `json:"deadline"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type TodoWasCreated

type TodoWasCreated struct {
	Title       string
	Description string
	Deadline    time.Time
}

type TodoWasDeleted

type TodoWasDeleted struct{}

type TodoWasDone

type TodoWasDone struct{}

type TodoWasUndone

type TodoWasUndone struct{}

type TodoWasUpdated

type TodoWasUpdated struct {
	Title       string
	Description string
	Deadline    time.Time
}

type UndoTodo

type UndoTodo struct {
	TodoID string `json:"todo_id" binding:"required,uuid4"`
}

type UpdateTodo

type UpdateTodo struct {
	TodoID      string    `json:"todo_id" binding:"required,uuid4"`
	Title       string    `binding:"required"`
	Description string    `binding:"required"`
	Deadline    time.Time `binding:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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