todo

package
v0.0.0-...-3d95c69 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const APIPath = "/todos/"

APIPath is path prefix

Variables

View Source
var EmptyTodo = Todo{}

EmptyTodo is empty todo model

Functions

This section is empty.

Types

type Controller

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

Controller handles http request.

func NewController

func NewController(repo Repository) *Controller

NewController return new bindTodo controller instance.

func (Controller) RegisterRoutes

func (controller Controller) RegisterRoutes(router gin.IRouter)

RegisterRoutes register handler routes.

type CreateTodoRequest

type CreateTodoRequest struct {
	Title    string `json:"title" example:"<new title>" binding:"required,min=4,max=100"`
	Contents string `json:"contents" example:"<new contents>" binding:"required,min=2,max=2048"`
}

CreateTodoRequest is request model for creating todo.

type Repository

type Repository interface {
	CreateTodo(todo Todo) (Todo, error)

	GetTodos() ([]Todo, error)

	GetTodoByTodoID(todoID string) (Todo, error)

	UpdateTodoByTodoID(todoID string, todo Todo) (Todo, error)

	RemoveTodoByTodoID(todoID string) (Todo, error)
}

Repository communications with db connection.

func NewRepository

func NewRepository(dbConn *db.Conn) Repository

NewRepository return new instance.

type Todo

type Todo struct {
	ID        uuid.UUID `gorm:"type:uuid;primary_key;"`
	Title     string
	Contents  string
	CreatedAt int64
}

Todo is todo data model.

func (Todo) TodoResponse

func (todo Todo) TodoResponse() TodoResponse

TodoResponse return instance of TodoResponse by Todo entity.

type TodoResponse

type TodoResponse struct {
	ID        uuid.UUID `json:"id"`
	Title     string    `json:"title"`
	Contents  string    `json:"contents"`
	CreatedAt time.Time `json:"create_at"`
}

TodoResponse is todo response model.

Jump to

Keyboard shortcuts

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