database

package
v0.0.0-...-52954b5 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(db *gorm.DB) error

func NewDatabase

func NewDatabase() (*gorm.DB, error)

func RandomString

func RandomString(n int) string

func UploadImage

func UploadImage(file *multipart.File, authHeader string, imgName string) error

Types

type CategoryOut

type CategoryOut struct {
	ID          uint   `json:"id,omitempty"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	GroupID     uint   `json:"GroupId"`
	Deletable   bool   `json:"deletable"`
}

func GetCategories

func GetCategories(GroupID uint, categoryServiceURL string) ([]CategoryOut, error)

type CategoryServiceResponse

type CategoryServiceResponse struct {
	Categories []CategoryOut `json:"categories"`
}

type Group

type Group struct {
	gorm.Model
	ID          uint   `gorm:"primaryKey;autoIncrement" json:"id,omitempty"`
	Name        string `gorm:"not null;unique" json:"name"`
	Description string `gorm:"" json:"description,omitempty"`
}

func (*Group) Out

func (g *Group) Out() GroupOut

func (*Group) OutWithCategories

func (g *Group) OutWithCategories() GroupOutWithCategories

type GroupIn

type GroupIn struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

func (*GroupIn) In

func (g *GroupIn) In() Group

type GroupOut

type GroupOut struct {
	ID          uint   `json:"id,omitempty"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

func GroupArrayOut

func GroupArrayOut(groupModels []Group) []GroupOut

type GroupOutWithCategories

type GroupOutWithCategories struct {
	ID          uint          `json:"id,omitempty"`
	Name        string        `json:"name"`
	Description string        `json:"description,omitempty"`
	Categories  []CategoryOut `json:"Categories"`
}

func GroupArrayOutWithCategories

func GroupArrayOutWithCategories(groupModels []Group) []GroupOutWithCategories

type Product

type Product struct {
	gorm.Model
	ID          uint    `gorm:"primaryKey;autoIncrement" json:"id,omitempty"`
	Name        string  `gorm:"not null;unique" json:"name"`
	Description string  `gorm:"" json:"description,omitempty"`
	Img         string  `gorm:"" json:"img,omitempty"`
	Price       float32 `gorm:"not null" json:"price"`
	Discount    int     `gorm:"" json:"discount"`
	CategoryID  uint    `gorm:"not null" json:"categoryID"`
}

func (*Product) IsDeletable

func (p *Product) IsDeletable(authHeader string) bool

func (*Product) Out

func (p *Product) Out(authHeader string) ProductOut

func (*Product) Update

func (p *Product) Update(data ProductIn) Product

type ProductIn

type ProductIn struct {
	Name        string  `json:"name"`
	Description string  `json:"description,omitempty"`
	Img         string  `json:"img,omitempty"`
	Price       float32 `json:"price"`
	Discount    int     `json:"discount"`
	CategoryID  uint    `json:"CategoryId"`
}

func DecodeMultipartRequest

func DecodeMultipartRequest(r *http.Request) (ProductIn, error)

func (*ProductIn) In

func (i *ProductIn) In() Product

type ProductOut

type ProductOut struct {
	ID          uint    `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description,omitempty"`
	Img         string  `json:"img,omitempty"`
	Price       float32 `json:"price"`
	Discount    int     `json:"discount"`
	CategoryID  uint    `json:"CategoryId"`
	Deletable   bool    `json:"deletable"`
}

func ProductArrayOut

func ProductArrayOut(models []Product, authHeader string) []ProductOut

type QuantityOrderedResponse

type QuantityOrderedResponse struct {
	Quantity uint `json:"quantity"`
}

Jump to

Keyboard shortcuts

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