model

package
v0.0.0-...-92bf345 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	ID        string    `json:"_id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type Category

type Category struct {
	ID        string    `json:"_id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type Discount

type Discount struct {
	ID         string    `json:"_id"`
	Name       string    `json:"name"`
	Percentage int       `json:"percentage"`
	CreatedAt  time.Time `json:"createdAt"`
	UpdatedAt  time.Time `json:"updatedAt"`
}

type Error

type Error struct {
	Status  int
	Message string
}

Error represents a custom error object that includes an HTTP status code

func NewError

func NewError(status int, message string) *Error

NewError creates a new Error object with the specified status code and message

func (*Error) Error

func (e *Error) Error() string

Error returns the error message

func (*Error) ToResponse

func (e *Error) ToResponse(c *fiber.Ctx) error

ToResponse converts the error into a JSON response

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

ErrorResponse represents the structure for error responses

type Product

type Product struct {
	ID          string      `json:"_id" validate:"required"`
	Name        string      `json:"name" validate:"required"`
	Description string      `json:"description" validate:"required"`
	Price       float64     `json:"price" validate:"required,gt=0"`
	Category    Category    `json:"category" validate:"required"`
	Parents     []Product   `json:"parents" validate:"customParentsValidation"`
	Children    []Product   `json:"children" validate:"customChildrenValidation"`
	Discounts   []Discount  `json:"discounts" validate:"customDiscountsValidation"`
	Attributes  []Attribute `json:"attributes" validate:"customAttributesValidation"`
	CreatedAt   time.Time   `json:"createdAt"`
	UpdatedAt   time.Time   `json:"updatedAt"`
}

func (*Product) ValidateProductData

func (p *Product) ValidateProductData() error

type ProductResponse

type ProductResponse struct {
	Message string   `json:"message"`
	Data    *Product `json:"data"`
}

Jump to

Keyboard shortcuts

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