assetapp

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: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App manages the set of app layer api functions for the asset domain.

func NewApp

func NewApp(assetBus *assetbus.Business) *App

NewApp constructs a asset app API for use.

func NewAppWithAuth

func NewAppWithAuth(assetBus *assetbus.Business, ath *auth.Auth) *App

NewAppWithAuth constructs a asset app API for use with auth support.

func (*App) Create

func (a *App) Create(ctx context.Context, app NewAsset) (Asset, error)

Create adds a new asset to the system.

func (*App) Delete

func (a *App) Delete(ctx context.Context, id uuid.UUID) error

Delete removes an existing asset.

func (*App) Query

func (a *App) Query(ctx context.Context, qp QueryParams) (query.Result[Asset], error)

Query returns a list of assets based on the filter, order and page.

func (*App) QueryByID

func (a *App) QueryByID(ctx context.Context, id uuid.UUID) (Asset, error)

QueryByID retrieves a single asset by its id.

func (*App) Update

func (a *App) Update(ctx context.Context, app UpdateAsset, id uuid.UUID) (Asset, error)

Update updates an existing asset.

type Asset

type Asset struct {
	ID                  string `json:"id"`
	TypeID              string `json:"type_id"`
	ConditionID         string `json:"condition_id"`
	Name                string `json:"name"`
	EstPrice            string `json:"est_price"`
	Price               string `json:"price"`
	MaintenanceInterval string `json:"maintenance_interval"`
	LifeExpectancy      string `json:"life_expectancy"`
	ModelNumber         string `json:"model_number"`
	IsEnabled           bool   `json:"is_enabled"`
	DateCreated         string `json:"date_created"`
	DateUpdated         string `json:"date_updated"`
	CreatedBy           string `json:"created_by"`
	UpdatedBy           string `json:"updated_by"`
}

func ToAppAsset

func ToAppAsset(bus assetbus.Asset) Asset

func ToAppAssets

func ToAppAssets(bus []assetbus.Asset) []Asset

func (Asset) Encode

func (app Asset) Encode() ([]byte, string, error)

Encode implements the encoder interface.

type NewAsset

type NewAsset struct {
	TypeID              string `json:"type_id" validate:"required"`
	ConditionID         string `json:"condition_id" validate:"required"`
	Name                string `json:"name" validate:"required"`
	EstPrice            string `json:"est_price"`
	Price               string `json:"price"`
	MaintenanceInterval string `json:"maintenance_interval"`
	LifeExpectancy      string `json:"life_expectancy"`
	ModelNumber         string `json:"model_number"`
	IsEnabled           bool   `json:"is_enabled"`
	CreatedBy           string `json:"created_by"`
}

func (*NewAsset) Decode

func (app *NewAsset) Decode(data []byte) error

Decode implements the decoder interface.

func (NewAsset) Validate

func (app NewAsset) Validate() error

Validate checks the data in the model is considered clean.

type QueryParams

type QueryParams struct {
	Page                string
	Rows                string
	OrderBy             string
	ID                  string
	TypeID              string
	ConditionID         string
	Name                string
	EstPrice            string
	Price               string
	MaintenanceInterval string
	LifeExpectancy      string
	ModelNumber         string
	IsEnabled           string
	StartDateCreated    string
	EndDateCreated      string
	StartDateUpdated    string
	EndDateUpdated      string
	CreatedBy           string
	UpdatedBy           string
}

type UpdateAsset

type UpdateAsset struct {
	TypeID              *string `json:"type_id"`
	ConditionID         *string `json:"condition_id"`
	Name                *string `json:"name"`
	EstPrice            *string `json:"est_price"`
	Price               *string `json:"price"`
	MaintenanceInterval *string `json:"maintenance_interval"`
	LifeExpectancy      *string `json:"life_expectancy"`
	ModelNumber         *string `json:"model_number"`
	IsEnabled           *bool   `json:"is_enabled"`
	UpdatedBy           *string `json:"updated_by"`
}

UpdateAsset contains information needed to update an asset.

func (*UpdateAsset) Decode

func (app *UpdateAsset) Decode(data []byte) error

Decode implements the decoder interface.

func (UpdateAsset) Validate

func (app UpdateAsset) Validate() error

Validate checks the data in the model is considered clean.

Jump to

Keyboard shortcuts

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