domain

package
v0.0.0-...-1668a93 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternalServerError will throw if any the Internal Server Error happen
	ErrInternalServerError = errors.New("internal server error")
	// ErrNotFound will throw if the requested item is not exists
	ErrNotFound = errors.New("your requested item is not found")
	// ErrConflict will throw if the current action already exists
	ErrConflict = errors.New("your item already exist")
	// ErrBadParamInput will throw if the given request-body or params is not valid
	ErrBadParamInput = errors.New("given param is not valid")
)

Functions

This section is empty.

Types

type Order

type Order struct {
	UserID        User      `json:"user_id" validate:"required"`
	PayMethod     string    `json:"paymethod" validate:"required"`
	TaxPrice      float32   `json:"tax_price" validate:"required"`
	ShippingPrice float32   `json:"shipping_price" validate:"required"`
	TotalPrice    float32   `json:"total_price" validate:"required"`
	IsPaid        bool      `json:"is_paid" validate:"required"`
	IsDelivered   bool      `json:"is_delivered" validate:"required"`
	PaidAt        time.Time `json:"paid_at" validate:"required"`
	DeliveredAt   time.Time `json:"delivered_at" validate:"required"`
	CreatedAt     time.Time `json:"created_at" validate:"required"`
}

type OrderItem

type OrderItem struct {
	ID        int64   `json:"id" verified:"required"`
	ProductID Product `json:"product_id" verified:"required"`
	OrderID   Order   `json:"order_id" verified:"required"`
	Name      string  `json:"name" verified:"required"`
	Qty       int     `json:"qty" verified:"required"`
	Price     float32 `json:"price" verified:"required"`
	Image     string  `json:"image" verified:"required"`
}

type OrderItemRepository

type OrderItemRepository interface {
	Fetch(ctx context.Context, cursor string, id int64) ([]OrderItem, string, error)
	GetByID(ctx context.Context, id int64) (OrderItem, error)
}

type OrderRepository

type OrderRepository interface {
	Fetch(ctx context.Context, cursor string, num int) ([]Order, string, error)
	GetByID(ctx context.Context, id int) (Order, error)
	Update(ctx context.Context, updateOrder *Order) error
	Store(ctx context.Context, createOrder *Order) error
	Delete(ctx context.Context, id int) error
}

type OrderUsecase

type OrderUsecase interface {
	Fetch(ctx context.Context, cursor string, num int) ([]Order, string, error)
	GetByID(ctx context.Context, id int) (Order, error)
	Update(ctx context.Context, updateOrder *Order) error
	Store(ctx context.Context, createOrder *Order) error
	Delete(ctx context.Context, id int) error
}

type Product

type Product struct {
	ID           int64     `json:"id" `
	UserID       User      `json:"user_id"`
	Image        string    `json:"image" validate:"required"`
	Name         string    `json:"name" validate:"required"`
	Brand        string    `json:"brand" validate:"required"`
	Category     string    `json:"category" validate:"required"`
	Description  string    `json:"description" validate:"required"`
	Rating       int       `json:"rating" validate:"required"`
	NumReviews   int       `json:"num_reviews" validate:"required"`
	Price        int       `json:"price" validate:"required"`
	CountInStock int       `json:"count_in_stock" validate:"required"`
	CreatedAt    time.Time `json:"created_at"`
}

type ProductRepository

type ProductRepository interface {
	Fetch(ctx context.Context, cursor string, num int64) (res []Product, nextCursor string, err error)
	GetByID(ctx context.Context, id int64) (Product, error)
	Update(ctx context.Context, ar *Product) error
	Store(ctx context.Context, a *Product) error
	Delete(ctx context.Context, id int64) error
}

type ProductUsecase

type ProductUsecase interface {
	Fetch(ctx context.Context, cursor string, num int64) ([]Product, string, error)
	GetByID(ctx context.Context, id int64) (Product, error)
	Update(ctx context.Context, ar *Product) error
	Store(context.Context, *Product) error
	Delete(ctx context.Context, id int64) error
}

type Review

type Review struct {
	ID        int64     `json:"id" verified:"required"`
	ProductID Product   `json:"product_id" verified:"required"`
	UserID    User      `json:"user_id" verified:"required"`
	Name      string    `json:"name" verified:"required"`
	Rating    int       `json:"rating" verified:"required"`
	Comment   string    `json:"comment" verified:"required"`
	CreatedAt time.Time `json:"created_at" verified:"required"`
}

type ReviewRepository

type ReviewRepository interface {
	Fetch(ctx context.Context, cursor string, num int) ([]Review, string, error)
	GetByID(ctx context.Context, id int64) (Review, error)
}

type RolesType

type RolesType string
const (
	RolesTypeAdmin      RolesType = "admin"
	RolesTypeUser       RolesType = "user"
	RolesTypeStaff      RolesType = "staff"
	RolesTypeSuperadmin RolesType = "superadmin"
	RolesTypeSuperstaff RolesType = "superstaff"
)

type ShippingAddress

type ShippingAddress struct {
	ID            int64   `json:"id" verified:"required"`
	OderID        Order   `json:"order_id" verified:"required"`
	Address       string  `json:"string" verified:"required"`
	City          string  `json:"city" verified:"required"`
	PostalCode    int     `json:"postal_code" verified:"required"`
	Country       string  `json:"country" verified:"required"`
	ShippingPrice float32 `json:"shipping_price" verified:"required"`
}

type ShippingAddressRepository

type ShippingAddressRepository interface {
	Fetch(ctx context.Context, cursor string, id int) ([]ShippingAddress, string, error)
	GetByID(ctx context.Context, id int64) (ShippingAddress, error)
}

type User

type User struct {
	ID             int64     `json:"id"`
	Username       string    `json:"username" validate:"required"`
	Email          string    `json:"email" validate:"required"`
	HashedPassword string    `json:"hashed_password" validate:"required"`
	IsVerified     bool      `json:"is_verified" validate:"required"`
	Role           string    `json:"role"`
	UpdatedAt      time.Time `json:"updated_at"`
	CreatedAt      time.Time `json:"created_at"`
}

User ...

type UserRepository

type UserRepository interface {
	Fetch(ctx context.Context, cursor string, num int64) (res []User, nextCursor string, err error)
	GetByID(ctx context.Context, id int64) (User, error)
	GetByUsername(ctx context.Context, username string) (User, error)
	Update(ctx context.Context, ar *User) error
	Store(ctx context.Context, a *User) error
	Delete(ctx context.Context, id int64) error
	Register(ctx context.Context, users *User) (err error)
	Login(ctx context.Context, username string, password string) (User, error)
}

UserRepository represent the User's repository contract

type UserUsecase

type UserUsecase interface {
	Fetch(ctx context.Context, cursor string, num int64) ([]User, string, error)
	GetByID(ctx context.Context, id int64) (User, error)
	Update(ctx context.Context, ar *User) error
	GetByUsername(ctx context.Context, username string) (User, error)
	Store(context.Context, *User) error
	Delete(ctx context.Context, id int64) error
	Register(ctx context.Context, users *User) (err error)
	Login(ctx context.Context, username string, password string) (User, error)
	CreateAdmin(ctx context.Context, user *User) (err error)
	CreateStaff(ctx context.Context, user *User) (err error)
}

UserUsecase represent the User's usecases

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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