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 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.
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 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
Click to show internal directories.
Click to hide internal directories.