domain

package
v0.0.0-...-991c831 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PERMIT = map[string][]string{
	"owner": {"/", "/login", "/register", "/books"},
	"user":  {"/login"},
}

Functions

This section is empty.

Types

type Book

type Book struct {
	Id     int    `json:"id"`
	Title  string `json:"title"`
	Author string `json:"author"`
	Length int    `json:"length"`
}

func (Book) ToResponseDto

func (b Book) ToResponseDto() *dto.BookResponse

type BookRepository

type BookRepository interface {
	GetAll(string) ([]Book, *errs.Error)
	GetById(int) (*Book, *errs.Error)
	Save(Book) (*Book, *errs.Error)
	Update(Book) (*Book, *errs.Error)
	Delete(int) *errs.Error
}

type BookRepositoryAdapter

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

func NewBookRepositoryAdapter

func NewBookRepositoryAdapter(client *sqlx.DB) BookRepositoryAdapter

func (BookRepositoryAdapter) Delete

func (b BookRepositoryAdapter) Delete(id int) *errs.Error

func (BookRepositoryAdapter) GetAll

func (b BookRepositoryAdapter) GetAll(sortBy string) ([]Book, *errs.Error)

func (BookRepositoryAdapter) GetById

func (b BookRepositoryAdapter) GetById(id int) (*Book, *errs.Error)

func (BookRepositoryAdapter) Save

func (b BookRepositoryAdapter) Save(book Book) (*Book, *errs.Error)

func (BookRepositoryAdapter) Update

func (b BookRepositoryAdapter) Update(book Book) (*Book, *errs.Error)

type User

type User struct {
	jwt.Payload
	Id       int    `json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
	Role     string `json:"role"`
}

func (User) Authorize

func (d User) Authorize(url string) *errs.Error

func (User) Claims

func (d User) Claims() (string, *errs.Error)

func (*User) Verify

func (d *User) Verify(token string) *errs.Error

type UserRepository

type UserRepository interface {
	Authenticate(string, string) (*User, *errs.Error)
	Authorize(string, string) *errs.Error
	NewUser(User) *errs.Error
}

type UserRepositoryAdapter

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

func NewUserRepositoryAdapter

func NewUserRepositoryAdapter(client *sqlx.DB) UserRepositoryAdapter

func (UserRepositoryAdapter) Authenticate

func (d UserRepositoryAdapter) Authenticate(username string, password string) (*User, *errs.Error)

func (UserRepositoryAdapter) Authorize

func (d UserRepositoryAdapter) Authorize(token string, url string) *errs.Error

func (UserRepositoryAdapter) NewUser

func (d UserRepositoryAdapter) NewUser(user User) *errs.Error

Jump to

Keyboard shortcuts

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