Documentation ¶
Index ¶
- Variables
- type Order
- type OrderItem
- type OrderItemRepository
- type OrderRepository
- type OrderUsecase
- type Product
- type ProductRepository
- type ProductUsecase
- type Review
- type ReviewRepository
- type RolesType
- type ShippingAddress
- type ShippingAddressRepository
- type User
- type UserRepository
- type UserUsecase
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 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 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 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 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
Source Files ¶
Click to show internal directories.
Click to hide internal directories.