service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

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

func NewAuthService

func NewAuthService(storage AuthStorage) *AuthService

func (*AuthService) CreateUser

func (s *AuthService) CreateUser(u core.User) (core.User, error)

func (*AuthService) GenerateToken

func (s *AuthService) GenerateToken(uname, pwd string) (string, error)

func (*AuthService) ParseToken

func (s *AuthService) ParseToken(accessToken string) (int, error)

type AuthStorage

type AuthStorage interface {
	CreateUser(core.User) (core.User, error)
	GetUser(username, password string) (core.User, error)
}

type Deps

type Deps struct {
	AuthStorage     AuthStorage
	TodoListStorage TodoListStorage
	TodoItemStorage TodoItemStorage
}

type Service

type Service struct {
	Auth     *AuthService
	TodoList *TodoListService
	TodoItem *TodoItemService
}

func NewService

func NewService(deps Deps) *Service

type TodoItemService

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

func NewTodoItemService

func NewTodoItemService(storage TodoItemStorage) *TodoItemService

func (*TodoItemService) CreateTodo

func (s *TodoItemService) CreateTodo(listID int, todo core.TodoItem) (core.TodoItem, error)

func (*TodoItemService) DeleteTodo

func (s *TodoItemService) DeleteTodo(todoID int) error

func (*TodoItemService) GetAllTodos

func (s *TodoItemService) GetAllTodos(listID int) ([]core.TodoItem, error)

func (*TodoItemService) GetTodoByID

func (s *TodoItemService) GetTodoByID(listID, todoID int) (core.TodoItem, error)

func (*TodoItemService) UpdateTodo

func (s *TodoItemService) UpdateTodo(todoID int, data core.UpdateItemData) (core.TodoItem, error)

type TodoItemStorage

type TodoItemStorage interface {
	CreateTodo(listID int, todo core.TodoItem) (core.TodoItem, error)
	GetAllTodos(listID int) ([]core.TodoItem, error)
	GetTodoByID(listID, todoID int) (core.TodoItem, error)
	UpdateTodo(todoID int, data core.UpdateItemData) (core.TodoItem, error)
	DeleteTodo(todoID int) error
}

type TodoListService

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

func NewTodoListService

func NewTodoListService(storage TodoListStorage) *TodoListService

func (*TodoListService) CreateList

func (s *TodoListService) CreateList(userID int, list core.Todolist) (core.Todolist, error)

func (*TodoListService) DeleteList

func (s *TodoListService) DeleteList(listID int) error

func (*TodoListService) GetAllLists

func (s *TodoListService) GetAllLists(userID int) ([]core.Todolist, error)

func (*TodoListService) GetListByID

func (s *TodoListService) GetListByID(userID, listID int) (core.Todolist, error)

func (*TodoListService) UpdateList

func (s *TodoListService) UpdateList(listID int, data core.UpdateListData) (core.Todolist, error)

type TodoListStorage

type TodoListStorage interface {
	CreateList(userID int, list core.Todolist) (core.Todolist, error)
	GetAllLists(userID int) ([]core.Todolist, error)
	GetListByID(userID, listID int) (core.Todolist, error)
	UpdateList(listID int, data core.UpdateListData) (core.Todolist, error)
	DeleteList(listID int) error
}

type TokenClaims

type TokenClaims struct {
	jwt.RegisteredClaims
	UserID int `json:"user_id"`
}

Jump to

Keyboard shortcuts

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