service

package
v0.0.0-...-15fe6cf Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: MIT Imports: 7 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(repo repository.Authorization) *AuthService

NewAuthService creates a new instance of AuthService

func (AuthService) CreateUser

func (a AuthService) CreateUser(user todo.User) (int, error)

CreateUser generates a hashed password and creates a new user

func (AuthService) GenerateToken

func (a AuthService) GenerateToken(username string, password string) (string, error)

GenerateToken generates a new JWT token if a user found for specified username and password

func (AuthService) ParseToken

func (a AuthService) ParseToken(accessToken string) (int, error)

ParseToken parses provided JWT access token and returns userID

type Authorization

type Authorization interface {
	CreateUser(user todo.User) (int, error)
	GenerateToken(username string, password string) (string, error)
	ParseToken(accessToken string) (int, error)
}

type Service

type Service struct {
	Authorization
	TodoList
	TodoItem
}

func NewService

func NewService(repos *repository.Repository) *Service

NewService creates a new instance of Service

type TodoItem

type TodoItem interface {
	Create(userId, listId int, item todo.TodoItem) (int, error)
	GetAll(userId, listId int) ([]todo.TodoItem, error)
	GetById(userId, itemId int) (todo.TodoItem, error)
	Delete(userId, itemId int) error
	Update(userId, itemId int, input todo.UpdateItemInput) error
}

type TodoItemService

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

func NewTodoItemService

func NewTodoItemService(repo repository.TodoItem, listRepo repository.TodoList) *TodoItemService

func (*TodoItemService) Create

func (s *TodoItemService) Create(userId, listId int, item todo.TodoItem) (int, error)

func (*TodoItemService) Delete

func (s *TodoItemService) Delete(userId, itemId int) error

func (*TodoItemService) GetAll

func (s *TodoItemService) GetAll(userId, listId int) ([]todo.TodoItem, error)

func (*TodoItemService) GetById

func (s *TodoItemService) GetById(userId, itemId int) (todo.TodoItem, error)

func (*TodoItemService) Update

func (s *TodoItemService) Update(userId, itemId int, input todo.UpdateItemInput) error

type TodoList

type TodoList interface {
	Create(userId int, list todo.TodoList) (int, error)
	GetAll(userId int) ([]todo.TodoList, error)
	FindById(userId, id int) (todo.TodoList, error)
	Delete(userId, id int) error
	Update(userId, id int, updateListRequest todo.UpdateTodoListRequest) error
}

type TodoListService

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

func NewTodoListService

func NewTodoListService(repo repository.TodoList) *TodoListService

NewTodoListService creates a new instance of TodoListService

func (TodoListService) Create

func (s TodoListService) Create(userId int, list todo.TodoList) (int, error)

Create creates a new TodoList for specified userId

func (TodoListService) Delete

func (s TodoListService) Delete(userId, id int) error

Delete deletes the list for specified user

func (TodoListService) FindById

func (s TodoListService) FindById(userId, id int) (todo.TodoList, error)

FindById return all Todolists for specified userId

func (TodoListService) GetAll

func (s TodoListService) GetAll(userId int) ([]todo.TodoList, error)

GetAll return all Todolists for specified userId

func (TodoListService) Update

func (s TodoListService) Update(userId, id int, updateListRequest todo.UpdateTodoListRequest) error

Update updates the specified TodoList

Jump to

Keyboard shortcuts

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