product

package
v1.20.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateProductInput

type CreateProductInput struct {
	Name     string         `json:"name"`
	Status   Status         `json:"status"`
	Metadata map[string]any `json:"metadata"`
}

CreateProductInput is a struct design to encapsulate request create payload data.

type Product

type Product struct {
	ID             string         `json:"id"`
	Name           string         `json:"name"`
	LedgerID       string         `json:"ledgerId"`
	OrganizationID string         `json:"organizationId"`
	Status         Status         `json:"status"`
	CreatedAt      time.Time      `json:"createdAt"`
	UpdatedAt      time.Time      `json:"updatedAt"`
	DeletedAt      *time.Time     `json:"deletedAt"`
	Metadata       map[string]any `json:"metadata"`
}

Product is a struct designed to encapsulate payload data.

type ProductPostgreSQLModel

type ProductPostgreSQLModel struct {
	ID                string
	Name              string
	LedgerID          string
	OrganizationID    string
	Status            string
	StatusDescription *string
	CreatedAt         time.Time
	UpdatedAt         time.Time
	DeletedAt         sql.NullTime
	Metadata          map[string]any
}

ProductPostgreSQLModel represents the entity Product into SQL context in Database

func (*ProductPostgreSQLModel) FromEntity

func (t *ProductPostgreSQLModel) FromEntity(product *Product)

FromEntity converts an entity.Product to ProductPostgreSQLModel

func (*ProductPostgreSQLModel) ToEntity

func (t *ProductPostgreSQLModel) ToEntity() *Product

ToEntity converts an ProductPostgreSQLModel to entity.Product

type Repository

type Repository interface {
	Create(ctx context.Context, product *Product) (*Product, error)
	FindByName(ctx context.Context, organizationID, ledgerID uuid.UUID, name string) (bool, error)
	FindAll(ctx context.Context, organizationID, ledgerID uuid.UUID, limit, page int) ([]*Product, error)
	FindByIDs(ctx context.Context, organizationID, ledgerID uuid.UUID, ids []uuid.UUID) ([]*Product, error)
	Find(ctx context.Context, organizationID, ledgerID, id uuid.UUID) (*Product, error)
	Update(ctx context.Context, organizationID, ledgerID, id uuid.UUID, product *Product) (*Product, error)
	Delete(ctx context.Context, organizationID, ledgerID, id uuid.UUID) error
}

Repository provides an interface for operations related to product entities.

type Status

type Status struct {
	Code        string  `json:"code"`
	Description *string `json:"description"`
}

Status structure for marshaling/unmarshalling JSON.

func (Status) IsEmpty

func (s Status) IsEmpty() bool

IsEmpty method that set empty or nil in fields

type UpdateProductInput

type UpdateProductInput struct {
	Name     string         `json:"name"`
	Status   Status         `json:"status"`
	Metadata map[string]any `json:"metadata"`
}

UpdateProductInput is a struct design to encapsulate request update payload data.

Jump to

Keyboard shortcuts

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