product

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidStatus = errors.New("invalid status")

Functions

This section is empty.

Types

type CreateDTO

type CreateDTO struct {
	PositionID uint
	Rfid       string
	Status     string
}

func (*CreateDTO) Ok

func (d *CreateDTO) Ok(l ut.Translator) (map[string]string, bool)

func (*CreateDTO) ToEntity

func (d *CreateDTO) ToEntity() (*Product, error)

type CreatedEvent

type CreatedEvent struct {
	Sender  user.User
	Session session.Session
	Data    CreateDTO
	Result  Product
}

func NewCreatedEvent

func NewCreatedEvent(ctx context.Context, data CreateDTO, result Product) (*CreatedEvent, error)

type DeletedEvent

type DeletedEvent struct {
	Sender  user.User
	Session session.Session
	Result  Product
}

func NewDeletedEvent

func NewDeletedEvent(ctx context.Context, result Product) (*DeletedEvent, error)

type Product

type Product struct {
	ID         uint
	PositionID uint
	Rfid       string
	Status     Status
	Position   *position.Position
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

type Repository

type Repository interface {
	GetPaginated(ctx context.Context, limit, offset int, sortBy []string) ([]*Product, error)
	Count(ctx context.Context) (int64, error)
	GetAll(ctx context.Context) ([]*Product, error)
	GetByID(ctx context.Context, id uint) (*Product, error)
	Create(ctx context.Context, data *Product) error
	CreateOrUpdate(ctx context.Context, data *Product) error
	Update(ctx context.Context, data *Product) error
	Delete(ctx context.Context, id uint) error
}

type Status

type Status string
const (
	InStock       Status = "in_stock"
	InDevelopment Status = "in_development"
	Approved      Status = "approved"
)

func NewStatus

func NewStatus(l string) (Status, error)

func (Status) IsValid

func (l Status) IsValid() bool

type UpdateDTO

type UpdateDTO struct {
	PositionID uint
	Rfid       string
	Status     string
}

func (*UpdateDTO) Ok

func (d *UpdateDTO) Ok(l ut.Translator) (map[string]string, bool)

func (*UpdateDTO) ToEntity

func (d *UpdateDTO) ToEntity(id uint) (*Product, error)

type UpdatedEvent

type UpdatedEvent struct {
	Sender  user.User
	Session session.Session
	Data    UpdateDTO
	Result  Product
}

func NewUpdatedEvent

func NewUpdatedEvent(ctx context.Context, data UpdateDTO, result Product) (*UpdatedEvent, error)

Jump to

Keyboard shortcuts

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