domain

package
v0.0.0-...-7d8e645 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// order status
	StatusPaymentPending  OrderStatusType = "payment pending"
	StatusOrderPlaced     OrderStatusType = "order placed"
	StatusOrderCancelled  OrderStatusType = "order cancelled"
	StatusOrderDelivered  OrderStatusType = "order delivered"
	StatusReturnRequested OrderStatusType = "return requested"
	StatusReturnApproved  OrderStatusType = "return approved"
	StatusReturnCancelled OrderStatusType = "return cancelled"
	StatusOrderReturned   OrderStatusType = "order returned"

	// payment type
	RazopayPayment        PaymentType = "razor pay"
	RazorPayMaximumAmount             = 50000 // this is only for initial admin can later change this
	CodPayment            PaymentType = "cod"
	CodMaximumAmount                  = 20000
	StripePayment         PaymentType = "stripe"
	StripeMaximumAmount               = 50000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	ID          uint   `json:"id" gorm:"primaryKey;unique"`
	Name        string `json:"name" gorm:"not null" binding:"required,min=2,max=50"`
	PhoneNumber string `json:"phone_number" gorm:"not null" binding:"required,min=10,max=10"`
	House       string `json:"house" gorm:"not null" binding:"required"`
	Area        string `json:"area" gorm:"not null"`
	LandMark    string `json:"land_mark" gorm:"not null" binding:"required"`
	City        string `json:"city" gorm:"not null"`
	Pincode     uint   `json:"pincode" gorm:"not null" binding:"required,numeric,min=6,max=6"`
	CountryID   uint   `json:"country_id" gorm:"not null" binding:"required"`
	Country     Country
	CreatedAt   time.Time `json:"created_at" gorm:"not null"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type Admin

type Admin struct {
	ID        uint      `json:"id" gorm:"primaryKey;not null"`
	UserName  string    `json:"user_name" gorm:"not null" binding:"required,min=3,max=15"`
	Email     string    `json:"email" gorm:"not null" binding:"required,email"`
	Password  string    `json:"password" gorm:"not null" binding:"required,min=5,max=30"`
	CreatedAt time.Time `json:"created_at" gorm:"not null"`
	UpdatedAt time.Time `json:"updated_at"`
}

type Brand

type Brand struct {
	ID   uint   `json:"id" gorm:"primaryKey;not null"`
	Name string `json:"brand_name" gorm:"unique;not null"`
}

type Cart

type Cart struct {
	ID              uint `json:"id" gorm:"primaryKey;not null"`
	UserID          uint `json:"user_id" gorm:"not null"`
	TotalPrice      uint `json:"total_price" gorm:"not null"`
	AppliedCouponID uint `json:"applied_coupon_id"`
	DiscountAmount  uint `json:"discount_amount"`
}

type CartItem

type CartItem struct {
	ID            uint `json:"id" gorm:"primaryKey;not null"`
	CartID        uint `json:"cart_id"`
	Cart          Cart
	ProductItemID uint        `json:"product_item_id" gorm:"not null"`
	ProductItem   ProductItem `json:"-"`
	Qty           uint        `json:"qty" gorm:"not null"`
}

type Category

type Category struct {
	ID         uint      `json:"-" gorm:"primaryKey;not null"`
	CategoryID uint      `json:"category_id"`
	Category   *Category `json:"-"`
	Name       string    `json:"category_name" gorm:"not null" binding:"required,min=1,max=30"`
}

for a products category main and sub category as self joining

type Country

type Country struct {
	ID          uint   `json:"id" gorm:"primaryKey;unique;"`
	CountryName string `json:"country_name" gorm:"unique;not null"`
}

type Coupon

type Coupon struct {
	CouponID   uint   `json:"coupon_id" gorm:"primaryKey;not null"`
	CouponName string `json:"coupon_name" gorm:"unique;not null" binding:"required,min=3,max=25"`
	CouponCode string `json:"coupon_code" gorm:"unique;not null"`

	ExpireDate       time.Time `json:"expire_date" gorm:"not null"`
	Description      string    `json:"description" gorm:"not null" binding:"required,min=6,max=150"`
	DiscountRate     uint      `json:"discount_rate" gorm:"not null" binding:"required,numeric,min=1,max=100"`
	MinimumCartPrice uint      `json:"minimum_cart_price" gorm:"not null" binding:"required,numeric,min=1"`
	Image            string    `json:"image" binding:"required"`
	BlockStatus      bool      `json:"block_status" gorm:"not null"`
	CreatedAt        time.Time `json:"created_at" gorm:"not null"`
	UpdatedAt        time.Time `json:"updated_at"`
}

type CouponUses

type CouponUses struct {
	CouponUsesID uint      `json:"coupon_uses_id" gorm:"primaryKey;not null"`
	CouponID     uint      `json:"coupon_id" gorm:"not null"`
	Coupon       Coupon    `json:"-"`
	UserID       uint      `json:"user_id" gorm:"not null"`
	User         User      `json:"-"`
	UsedAt       time.Time `json:"used_at" gorm:"not null"`
}

which is for store the user who are used coupon

type Offer

type Offer struct {
	ID           uint      `json:"id" gorm:"primaryKey;not null" swaggerignore:"true"`
	Name         string    `json:"offer_name" gorm:"not null;unique" binding:"required"`
	Description  string    `json:"description" gorm:"not null" binding:"required,min=6,max=50"`
	DiscountRate uint      `json:"discount_rate" gorm:"not null" binding:"required,numeric,min=1,max=100"`
	StartDate    time.Time `json:"start_date" gorm:"not null" binding:"required"`
	EndDate      time.Time `json:"end_date" gorm:"not null" binding:"required,gtfield=StartDate"`
}

offer

type OfferCategory

type OfferCategory struct {
	ID         uint     `json:"id" gorm:"primaryKey;not null"`
	OfferID    uint     `json:"offer_id" gorm:"not null"`
	Offer      Offer    `json:"-"`
	CategoryID uint     `json:"category_id" gorm:"not null"`
	Category   Category `json:"-"`
}

type OfferProduct

type OfferProduct struct {
	ID        uint `json:"id" gorm:"primaryKey;not null"`
	OfferID   uint `json:"offer_id" gorm:"not null"`
	Offer     Offer
	ProductID uint `json:"product_id" gorm:"not null"`
	Product   Product
}

type OrderLine

type OrderLine struct {
	ID            uint      `json:"id" gorm:"primaryKey;not null"`
	ProductItemID uint      `json:"product_item_id" gorm:"not null"`
	ShopOrderID   uint      `json:"shop_order_id" gorm:"not null"`
	ShopOrder     ShopOrder `json:"-"`
	Qty           uint      `json:"qty" gorm:"not null"`
	Price         uint      `json:"price" gorm:"not null"`
}

type OrderReturn

type OrderReturn struct {
	ID           uint      `json:"id" gorm:"primaryKey;not null"`
	ShopOrderID  uint      `json:"shop_order_id" gorm:"not null;unique"`
	ShopOrder    ShopOrder `json:"-"`
	RequestDate  time.Time `json:"request_date" gorm:"not null"`
	ReturnReason string    `json:"return_reason" gorm:"not null"`
	RefundAmount uint      `json:"refund_amount" gorm:"not null"`

	IsApproved   bool      `json:"is_approved"`
	ReturnDate   time.Time `json:"return_date"`
	ApprovalDate time.Time `json:"approval_date"`
	AdminComment string    `json:"admin_comment"`
}

type OrderStatus

type OrderStatus struct {
	ID     uint            `json:"id" gorm:"primaryKey;not null"`
	Status OrderStatusType `json:"status" gorm:"unique;not null"`
}

type OrderStatusType

type OrderStatusType string

for defining ENUM stasues

type OtpSession

type OtpSession struct {
	ID       uint      `json:"id" gorm:"primaryKey;not null"`
	OtpID    string    `json:"otp_id" gorm:"unique;not null"`
	UserID   uint      `json:"user_id" gorm:"not null"`
	Phone    string    `json:"phone" gorm:"not null"`
	ExpireAt time.Time `json:"expire_at" gorm:"not null"`
}

type PaymentMethod

type PaymentMethod struct {
	ID            uint        `json:"id" gorm:"primaryKey;not null"`
	Name          PaymentType `json:"name" gorm:"unique;not null"`
	BlockStatus   bool        `json:"block_status" gorm:"not null;default:false"`
	MaximumAmount uint        `json:"maximum_amount" gorm:"not null"`
}

type PaymentType

type PaymentType string

payment types

type Product

type Product struct {
	ID            uint      `json:"id" gorm:"primaryKey;not null"`
	Name          string    `json:"product_name" gorm:"not null" binding:"required,min=3,max=50"`
	Description   string    `json:"description" gorm:"not null" binding:"required,min=10,max=100"`
	CategoryID    uint      `json:"category_id" binding:"omitempty,numeric"`
	Category      Category  `json:"-"`
	BrandID       uint      `gorm:"not null"`
	Brand         Brand     `json:"-"`
	Price         uint      `json:"price" gorm:"not null" binding:"required,numeric"`
	DiscountPrice uint      `json:"discount_price"`
	Image         string    `json:"image" gorm:"not null"`
	CreatedAt     time.Time `json:"created_at" gorm:"not null"`
	UpdatedAt     time.Time `json:"updated_at"`
}

represent a model of product

type ProductConfiguration

type ProductConfiguration struct {
	ProductItemID     uint            `json:"product_item_id" gorm:"not null"`
	ProductItem       ProductItem     `json:"-"`
	VariationOptionID uint            `json:"variation_option_id" gorm:"not null"`
	VariationOption   VariationOption `json:"-"`
}

type ProductImage

type ProductImage struct {
	ID            uint        `json:"id" gorm:"primaryKey;not null"`
	ProductItemID uint        `json:"product_item_id" gorm:"not null"`
	ProductItem   ProductItem `json:"-"`
	Image         string      `json:"image" gorm:"not null"`
}

to store a url of productItem Id along a unique url so we can ote multiple images url for a ProductItem one to many connection

type ProductItem

type ProductItem struct {
	ID            uint `json:"id" gorm:"primaryKey;not null"`
	ProductID     uint `json:"product_id" gorm:"not null" binding:"required,numeric"`
	Product       Product
	QtyInStock    uint      `json:"qty_in_stock" gorm:"not null" binding:"required,numeric"`
	Price         uint      `json:"price" gorm:"not null" binding:"required,numeric"`
	SKU           string    `json:"sku" gorm:"unique;not null"`
	DiscountPrice uint      `json:"discount_price"`
	CreatedAt     time.Time `json:"created_at" gorm:"not null"`
	UpdatedAt     time.Time `json:"updated_at"`
}

this for a specific variant of product

type RefreshSession

type RefreshSession struct {
	TokenID      string    `json:"token_id" gorm:"primaryKey;not null"`
	UserID       uint      `json:"user_id" gorm:"not null"`
	RefreshToken string    `json:"refresh_token" gorm:"not null"`
	ExpireAt     time.Time `json:"expire_at" gorm:"not null"`
	IsBlocked    bool      `json:"is_blocked" gorm:"not null;default:false"`
}

type ShopOrder

type ShopOrder struct {
	ID              uint          `json:"shop_order_id" gorm:"primaryKey;not null"`
	UserID          uint          `json:"user_id" gorm:"not null"`
	User            User          `json:"-"`
	OrderDate       time.Time     `json:"order_date" gorm:"not null"`
	AddressID       uint          `json:"address_id" gorm:"not null"`
	Address         Address       `json:"-"`
	OrderTotalPrice uint          `json:"order_total_price" gorm:"not null"`
	Discount        uint          `json:"discount" gorm:"not null"`
	OrderStatusID   uint          `json:"order_status_id" gorm:"not null"`
	OrderStatus     OrderStatus   `json:"-"`
	PaymentMethodID uint          `json:"payment_method_id"`
	PaymentMethod   PaymentMethod `json:"-"`
}

type Transaction

type Transaction struct {
	TransactionID   uint            `json:"transaction_id" gorm:"primaryKey;not null"`
	WalletID        uint            `json:"wallet_id" gorm:"not null"`
	Wallet          Wallet          `json:"-"`
	TransactionDate time.Time       `json:"transaction_time" gorm:"not null"`
	Amount          uint            `json:"amount" gorm:"not null"`
	TransactionType TransactionType `json:"transaction_type" gorm:"not null"`
}

type TransactionType

type TransactionType string
const (
	Debit  TransactionType = "DEBIT"
	Credit TransactionType = "CREDIT"
)

type User

type User struct {
	ID          uint      `json:"id" gorm:"primaryKey;unique"`
	Age         uint      `json:"age" binding:"required,numeric"`
	GoogleImage string    `json:"google_profile_image"`
	FirstName   string    `json:"first_name" gorm:"not null" binding:"required,min=2,max=50"`
	LastName    string    `json:"last_name" gorm:"not null" binding:"required,min=1,max=50"`
	UserName    string    `json:"user_name" gorm:"not null;unique" binding:"required,min=3,max=15"`
	Email       string    `json:"email" gorm:"unique;not null" binding:"required,email"`
	Phone       string    `json:"phone" gorm:"unique" binding:"required,min=10,max=10"`
	Password    string    `json:"password" binding:"required"`
	Verified    bool      `json:"verified" gorm:"default:false"`
	BlockStatus bool      `json:"block_status" gorm:"not null;default:false"`
	CreatedAt   time.Time `json:"created_at" gorm:"not null"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type UserAddress

type UserAddress struct {
	ID        uint `json:"id" gorm:"primaryKey;unique"`
	UserID    uint `json:"user_id" gorm:"not null"`
	User      User
	AddressID uint `json:"address_id" gorm:"not null"`
	Address   Address
	IsDefault bool `json:"is_default"`
}

many to many join

type Variation

type Variation struct {
	ID         uint     `json:"-" gorm:"primaryKey;not null"`
	CategoryID uint     `json:"category_id" gorm:"not null" binding:"required,numeric"`
	Category   Category `json:"-"`
	Name       string   `json:"variation_name" gorm:"not null" binding:"required"`
}

variation means size color etc..

type VariationOption

type VariationOption struct {
	ID          uint      `json:"-" gorm:"primaryKey;not null"`
	VariationID uint      `json:"variation_id" gorm:"not null" binding:"required,numeric"` // a specific field of variation like color/size
	Variation   Variation `json:"-"`
	Value       string    `json:"variation_value" gorm:"not null" binding:"required"` // the variations value like blue/XL
}

variation option means values are like s,m,xl for size and blue,white,black for Color

type Wallet

type Wallet struct {
	ID          uint `json:"wallet_id" gorm:"primaryKey;not null"`
	UserID      uint `json:"user_id" gorm:"not null"`
	User        User `json:"-"`
	TotalAmount uint `json:"total_amount" gorm:"not null"`
}

type WishList

type WishList struct {
	ID            uint `json:"id" gorm:"primaryKey;not null"`
	UserID        uint `json:"user_id" gorm:"not null"`
	User          User
	ProductItemID uint `json:"product_item_id" gorm:"not null"`
	ProductItem   ProductItem
}

Wish List

Jump to

Keyboard shortcuts

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