tasks

package
v0.0.0-...-b9b4979 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATE = iota
	REWRITE
	DECLINE
)

Variables

This section is empty.

Functions

func RegisterHandlers

func RegisterHandlers(mux *httprouter.Router, service Service, logger log.Logger)

RegisterHandlers registers handlers for Tasks API methods

Types

type Color

type Color entity.Color

type Date

type Date entity.Date

type Label

type Label struct {
	Name  Name  `json:"text"`
	Color Color `json:"color"`
}

type Labels

type Labels entity.Labels

type Name

type Name entity.Name

type Repository

type Repository interface {
	// Get returns all tasks for user with specified id
	Get(userId int64) ([]entity.Task, error)
	// GetById returns single task with specified id
	GetById(userId, taskId int64) (entity.Task, error)
	// Create saves new task
	Create(request *entity.Task) error
	// Update modifies task
	Update(request *entity.Task) error
	// Delete removes task with specified id
	Delete(userId, taskId int64) error
}

Repository encapsulates the logic to access tasks from the data source.

func NewRepository

func NewRepository(db *sql.DB, logger log.Logger) Repository

NewRepository creates a new tasks repository.

type Service

type Service interface {
	// Get returns all tasks for user with specified id
	Get(userId int64) ([]entity.Task, error)
	// GetById returns single task with specified id
	GetById(userId, taskId int64) (entity.Task, error)
	// Set creates / complete modifies existent task
	Set(request *SetTaskRequest) (entity.Task, error)
	// Update modifies task
	Update(request *UpdateTaskRequest) (entity.Task, error)
	// Delete removes task with specified id
	Delete(userId, taskId int64) (entity.Task, error)
}

Service encapsulates usecase logic for tasks.

func NewService

func NewService(r Repository) Service

NewService creates a new user service.

type SetTaskRequest

type SetTaskRequest struct {
	Mode                 int64  `json:"-"`
	TaskId               int64  `json:"task_id"`
	UserId               int64  `json:"-"`
	Name                 Name   `json:"name"`
	Description          Text   `json:"description,omitempty"`
	CreatedOn            Date   `json:"createdOn"`
	DueDate              Date   `json:"dueDate"`
	SchtirlichHumorescue Text   `json:"schtirlichHumorescue"`
	Labels               Labels `json:"labels"`
	Status               Status `json:"status"`
}

CreateTaskRequest represents task creation / complete update request description, humorescue and labels are optional

func (*SetTaskRequest) Validate

func (t *SetTaskRequest) Validate() error

type Status

type Status entity.Status

type Text

type Text entity.Text

type UpdateTaskRequest

type UpdateTaskRequest struct {
	TaskId               int64  `json:"-"`
	UserId               int64  `json:"-"`
	Name                 Name   `json:"name,omitempty"`
	Description          Text   `json:"description,omitempty"`
	DueDate              Date   `json:"dueDate,omitempty"`
	SchtirlichHumorescue Text   `json:"schtirlichHumorescue,omitempty"`
	Labels               Labels `json:"labels,omitempty"`
	Status               Status `json:"status,omitempty"`
}

UpdateTaskRequest represents task modify request all of the fields is optional

func (*UpdateTaskRequest) Validate

func (t *UpdateTaskRequest) Validate() error

Jump to

Keyboard shortcuts

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