assettypebus

package
v0.0.0-...-16ef530 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrderByID          = "asset_type_id"
	OrderByName        = "name"
	OrderByDescription = "description"
)

Set of fields that the results can be ordered by.

Variables

View Source
var (
	ErrNotFound              = errors.New("asset type not found")
	ErrAuthenticationFailure = errors.New("authentication failed")
	ErrUniqueEntry           = errors.New("asset type entry is not unique")
)

Set of error variables for CRUD operations.

View Source
var DefaultOrderBy = order.NewBy(OrderByName, order.ASC)

DefaultOrderBy represents the default way we sort.

Functions

This section is empty.

Types

type AssetType

type AssetType struct {
	ID          uuid.UUID
	Name        string
	Description string
}

AssetType represents information about an individual asset type.

func TestSeedAssetTypes

func TestSeedAssetTypes(ctx context.Context, n int, api *Business) ([]AssetType, error)

TestSeedAssetTypes is a helper method for testing.

type Business

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

Business manages the set of APIs for asset type access.

func NewBusiness

func NewBusiness(log *logger.Logger, delegate *delegate.Delegate, storer Storer) *Business

NewBusiness constructs a asset type business API for use.

func (*Business) Count

func (b *Business) Count(ctx context.Context, filter QueryFilter) (int, error)

Count returns the total number of asset types.

func (*Business) Create

func (b *Business) Create(ctx context.Context, nat NewAssetType) (AssetType, error)

Create adds a new asset type to the system.

func (*Business) Delete

func (b *Business) Delete(ctx context.Context, at AssetType) error

Delete removes an asset type from the system.

func (*Business) NewWithTx

func (b *Business) NewWithTx(tx sqldb.CommitRollbacker) (*Business, error)

NewWithTx constructs a new business value that will use the specified transaction in any store related calls.

func (*Business) Query

func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]AssetType, error)

Query retrieves a list of existing asset types from the system.

func (*Business) QueryByID

func (b *Business) QueryByID(ctx context.Context, id uuid.UUID) (AssetType, error)

QueryByID finds the asset type by the specified ID.

func (*Business) Update

func (b *Business) Update(ctx context.Context, at AssetType, uat UpdateAssetType) (AssetType, error)

Update updates an existing asset type.

type NewAssetType

type NewAssetType struct {
	Name        string
	Description string
}

func TestNewAssetTypes

func TestNewAssetTypes(n int) []NewAssetType

TestNewAssetTypes is a helper method for testing.

type QueryFilter

type QueryFilter struct {
	ID          *uuid.UUID
	Name        *string
	Description *string
}

QueryFilter holds the available fields a query can be filtered on. We are using pointer semantics because the With API mutates the value.

type Storer

type Storer interface {
	NewWithTx(tx sqldb.CommitRollbacker) (Storer, error)
	Create(ctx context.Context, assetType AssetType) error
	Update(ctx context.Context, assetType AssetType) error
	Delete(ctx context.Context, assetType AssetType) error
	Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]AssetType, error)
	Count(ctx context.Context, filter QueryFilter) (int, error)
	QueryByID(ctx context.Context, assetTypeID uuid.UUID) (AssetType, error)
}

Storer interface declares the behavior this package needs to persist and retrieve data.

type UpdateAssetType

type UpdateAssetType struct {
	Name        *string
	Description *string
}

Directories

Path Synopsis
stores

Jump to

Keyboard shortcuts

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