domain

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternal = errors.New("internal")
	ErrNotFound = errors.New("not found")
	ErrConflict = errors.New("conflict")
)

Functions

This section is empty.

Types

type AccessDetails

type AccessDetails struct {
	AccessUuid string
	UserId     int
}

type AuthHandler

type AuthHandler interface {
	Login(c *gin.Context)
	Refresh(c *gin.Context)
	Logout(c *gin.Context)
}

type AuthService

type AuthService interface {
	ValidateToken(r *http.Request) (*jwt.Token, error)
	TokenValid(r *http.Request) error
	CreateToken(userid uint) (*TokenDetails, error)
	CreateAuth(userid uint, td *TokenDetails) error
	DeleteTokens(authD *AccessDetails) error
	ExtractTokenMetadata(r *http.Request) (*AccessDetails, error)
	FetchAuth(authD *AccessDetails) (uint64, error)
	DeleteAuth(givenUuid string) (int64, error)
}

type MysqlClient

type MysqlClient interface {
	GetClient() *gorm.DB
}

type Product

type Product struct {
	gorm.Model
	Name        string  `json:"name" validate:"required,min=2,max=45"`
	Price       float32 `json:"price" validate:"required"`
	Description string  `json:"description" validate:"required"`
}

swagger:model Product

func ToProduct

func ToProduct(productDTO ProductDTO) Product

type ProductDTO

type ProductDTO struct {
	ID          uint    `json:"id,string,omitempty"`
	Name        string  `json:"name" validate:"required,min=2,max=45"`
	Price       float32 `json:"price" validate:"required"`
	Description string  `json:"description" validate:"required"`
}

swagger:model ProductDTO

func ToProductDTO

func ToProductDTO(product Product) ProductDTO

func ToProductDTOs

func ToProductDTOs(products []Product) []ProductDTO

type ProductHandler

type ProductHandler interface {
	GetAllProducts(c *gin.Context)
	GetProductByID(c *gin.Context)
	AddProduct(c *gin.Context)
	UpdateProduct(c *gin.Context)
	DeleteProduct(c *gin.Context)
}

type ProductRepository

type ProductRepository interface {
	GetAllProducts() []Product
	GetProductByID(id uint) Product
	AddProduct(product Product) Product
	DeleteProduct(product Product)
}

type ProductService

type ProductService interface {
	GetAllProducts() []Product
	GetProductByID(id uint) Product
	AddProduct(product Product) Product
	DeleteProduct(product Product)
}

type RedisClient

type RedisClient interface {
	GetClient() *redis.Client
}

type TokenDetails

type TokenDetails struct {
	AccessToken  string
	RefreshToken string
	AccessUuid   string
	RefreshUuid  string
	AtExpires    int64
	RtExpires    int64
}

type User

type User struct {
	gorm.Model
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

swagger:model User

func ToUser

func ToUser(userDTO UserDTO) User

type UserDTO

type UserDTO struct {
	ID       uint   `json:"id,string,omitempty"`
	Username string `json:"username" validate:"required"`
	Password string `json:"password" validate:"required"`
}

swagger:model UserDTO

func ToUserDTO

func ToUserDTO(user User) UserDTO

func ToUserDTOs

func ToUserDTOs(users []User) []UserDTO

type UserHandler

type UserHandler interface {
	GetAllUsers(c *gin.Context)
	GetUserByID(c *gin.Context)
	AddUser(c *gin.Context)
	UpdateUser(c *gin.Context)
	DeleteUser(c *gin.Context)
}

type UserHandlerDynamoDb

type UserHandlerDynamoDb interface {
	Update(c *gin.Context)
	Find(c *gin.Context)
	Insert(c *gin.Context)
	Delete(c *gin.Context)
}

type UserRepository

type UserRepository interface {
	GetAllUsers() []User
	GetUserByID(id uint) User
	GetUserByUsername(username string) User
	AddUser(user User) User
	DeleteUser(user User)
}

type UserRepositoryCtx

type UserRepositoryCtx interface {
	Update(ctx context.Context, user User) error
	Find(ctx context.Context, id uint) (User, error)
	Insert(ctx context.Context, user User) error
	Delete(ctx context.Context, id uint) error
}

type UserService

type UserService interface {
	GetAllUsers() []User
	GetUserByID(id uint) User
	AddUser(user User) User
	GetUserByUsername(username string) User
	DeleteUser(User)
}

type UserServiceDynamoDb

type UserServiceDynamoDb interface {
	Update(ctx context.Context, user User) error
	Find(ctx context.Context, id uint) (User, error)
	Insert(ctx context.Context, user User) error
	Delete(ctx context.Context, id uint) error
}

Jump to

Keyboard shortcuts

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