domain

package
v0.0.0-...-da803b4 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	ID           int64   `json:"id" swaggerignore:"true"`
	Title        string  `json:"title" validate:"required"`
	Subtitle     string  `json:"subtitle" validate:"required"`
	AboutTheBook string  `json:"about_the_book" db:"about_the_book" validate:"required"`
	PageCount    int64   `json:"page_count" db:"page_count" validate:"required"`
	Price        float64 `json:"price" validate:"required"`
	Image        string  `json:"image" validate:"required,url"`
	Language     string  `json:"language" validate:"required"`
	AuthorName   string  `json:"author_name" db:"author_name" validate:"required"`
	AuthorAvatar string  `json:"author_avatar" db:"author_avatar" validate:"required,url"`
	CategoryId   int64   `json:"category_id" db:"category_id" validate:"required"`
}

Book is representing the Book data struct

type BookRepository

type BookRepository interface {
	GetByID(ctx context.Context, id int64) (*Book, error)
	GetAll(ctx context.Context, p *pagination.PaginationQuery) ([]Books, error)
	GetByCategory(ctx context.Context, category string, p *pagination.PaginationQuery) ([]Books, error)
	InsertBook(ctx context.Context, book *Book) (int64, error)
	DeleteBook(ctx context.Context, id int64) error
}

BookRepository represent the Book's repository contract

type BookUseCase

type BookUseCase interface {
	GetByID(ctx context.Context, id int64) (*Book, error)
	GetByCategory(ctx context.Context, category string, p *pagination.PaginationQuery) ([]Books, error)
	GetAll(ctx context.Context, p *pagination.PaginationQuery) ([]Books, error)
	InsertBook(ctx context.Context, book *Book) (int64, error)
	DeleteBook(ctx context.Context, id int64) error
}

BookUsecase represent the Book's usecases

type Books

type Books struct {
	ID         int64  `json:"id"`
	Title      string `json:"title"`
	Subtitle   string `json:"subtitle"`
	Image      string `json:"image"`
	AuthorName string `json:"author_name" db:"author_name"`
}

type Category

type Category struct {
	ID   int64  `json:"id" swaggerignore:"true"`
	Name string `json:"name" validate:"required"`
}

type CategoryRepository

type CategoryRepository interface {
	GetAll(ctx context.Context, params *p.PaginationQuery) ([]Category, error)
	GetByID(ctx context.Context, id int64) (*Category, error)
	InsertCategory(ctx context.Context, c *Category) (int64, error)
	DeleteCategory(ctx context.Context, id int64) error
	UpdateCategory(ctx context.Context, c *Category) error
}

type CategoryUseCase

type CategoryUseCase interface {
	GetAll(ctx context.Context, params *p.PaginationQuery) ([]Category, error)
	GetByID(ctx context.Context, id int64) (*Category, error)
	InsertCategory(ctx context.Context, c *Category) (int64, error)
	DeleteCategory(ctx context.Context, id int64) error
	UpdateCategory(ctx context.Context, c *Category) error
}

type GetUserResponse

type GetUserResponse struct {
	ID      int64  `json:"id"`
	Email   string `json:"email"`
	IsStaff bool   `json:"is_staff" db:"is_staff"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email" form:"email" validate:"required,email"`
	Password string `json:"password" form:"password" validate:"required,min=8,max=28"`
}

type SignUpRequest

type SignUpRequest struct {
	Email                string `json:"email" form:"email" validate:"required,email"`
	Password             string `json:"password" form:"password" validate:"required,eqfield=PasswordConfirmation,min=8,max=28"`
	PasswordConfirmation string `json:"password_confirmation" form:"password_confirmation" validate:"required,min=8,max=28"`
	HashedPassword       string `json:"hashed_password" swaggerignore:"true"`
}

type TokenResponse

type TokenResponse struct {
	Message string `json:"message"`
	Token   string `json:"token"`
}

type User

type User struct {
	ID       int64  `json:"id"`
	Email    string `json:"email"`
	Password string `json:"password"`
	IsStaff  bool   `json:"is_staff" db:"is_staff"`
}

type UserRepository

type UserRepository interface {
	Insert(ctx context.Context, user *SignUpRequest) (int64, error)
	FindById(ctx context.Context, id int64) (*GetUserResponse, error)
	FindByEmail(ctx context.Context, email string) (*User, error)
	Delete(ctx context.Context, userId int64) error
}

UserRepository represent the User's repository contract

type UserUseCase

type UserUseCase interface {
	GetUserByID(ctx context.Context, id int64) (*GetUserResponse, error)
	RegisterUser(ctx context.Context, user *SignUpRequest) (*TokenResponse, error)
	LoginUser(ctx context.Context, user *LoginRequest) (*TokenResponse, error)
	DeleteUser(ctx context.Context, userId int64) error
}

UserUsecase represent the User's usecases

Jump to

Keyboard shortcuts

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