categories

package
v0.0.0-...-f6515dd Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package categories handles equipment category routes, business logic, and data access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateEquipmentCategory

type CreateEquipmentCategory struct {
	ID        string
	CompanyID string
	Name      string
}

CreateEquipmentCategory holds the data required to create a new equipment category.

type EquipmentCategory

type EquipmentCategory struct {
	ID        string
	CompanyID string
	Name      string
}

EquipmentCategory represents an equipment category belonging to a company.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler holds dependencies for equipment category HTTP handlers.

func NewHandler

func NewHandler(svc *Service, cache map[string]*template.Template) *Handler

NewHandler returns a new Handler wired with svc.

func (*Handler) Routes

func (h *Handler) Routes(m *forma.HTML)

Routes registers equipment category HTML form routes on m.

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository provides data access for equipment equipmentCategories.

func NewRepository

func NewRepository(db *sql.DB) *Repository

NewRepository returns a new Repository.

func (*Repository) Create

Create inserts a new equipment category.

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, id string) error

Delete removes the category. Returns database.ErrForeignKeyViolation when inventory items are still assigned to the category.

func (*Repository) GetByCompanyID

func (r *Repository) GetByCompanyID(ctx context.Context, companyID string) ([]EquipmentCategory, error)

GetByCompanyID returns all equipmentCategories belonging to companyID.

func (*Repository) GetByID

func (r *Repository) GetByID(ctx context.Context, id string) (*EquipmentCategory, error)

GetByID returns the category with id, or database.ErrNotFound when it does not exist.

func (*Repository) Update

Update updates the name of the category identified by u.ID.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service implements business logic for equipment equipmentCategories.

func NewService

func NewService(repo *Repository) *Service

NewService returns a new Service backed by repo.

func (*Service) Create

Create creates a new equipment category.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete removes a category. Returns database.ErrForeignKeyViolation when inventory items are still assigned to it.

func (*Service) GetByCompanyID

func (s *Service) GetByCompanyID(ctx context.Context, companyID string) ([]EquipmentCategory, error)

GetByCompanyID returns all equipmentCategories belonging to companyID.

func (*Service) GetByID

func (s *Service) GetByID(ctx context.Context, id string) (*EquipmentCategory, error)

GetByID returns the category with id.

func (*Service) Update

Update updates the name of an equipment category.

type UpdateEquipmentCategory

type UpdateEquipmentCategory struct {
	ID   string
	Name string
}

UpdateEquipmentCategory holds the data required to update an equipment category.

Jump to

Keyboard shortcuts

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