tranapp

package
v0.0.0-...-c624722 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package tranapp maintains the app layer api for the tran domain.

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 tran domain.

func NewApp

func NewApp(userBus *userbus.Business, productBus *productbus.Business) *App

NewApp constructs a tran app API for use.

func (*App) Create

func (a *App) Create(ctx context.Context, app NewTran) (Product, error)

Create adds a new user and product at the same time under a single transaction.

type NewProduct

type NewProduct struct {
	Name     string  `json:"name" validate:"required"`
	Cost     float64 `json:"cost" validate:"required,gte=0"`
	Quantity int     `json:"quantity" validate:"required,gte=1"`
}

NewProduct is what we require from clients when adding a Product.

func (NewProduct) Validate

func (app NewProduct) Validate() error

Validate checks the data in the model is considered clean.

type NewTran

type NewTran struct {
	Product NewProduct `json:"product"`
	User    NewUser    `json:"user"`
}

NewTran represents an example of cross domain transaction at the application layer.

type NewUser

type NewUser struct {
	Name            string   `json:"name" validate:"required"`
	Email           string   `json:"email" validate:"required,email"`
	Roles           []string `json:"roles" validate:"required"`
	Department      string   `json:"department"`
	Password        string   `json:"password" validate:"required"`
	PasswordConfirm string   `json:"passwordConfirm" validate:"eqfield=Password"`
}

NewUser contains information needed to create a new user.

func (NewUser) Validate

func (app NewUser) Validate() error

Validate checks the data in the model is considered clean.

type Product

type Product struct {
	ID          string  `json:"id"`
	UserID      string  `json:"userID"`
	Name        string  `json:"name"`
	Cost        float64 `json:"cost"`
	Quantity    int     `json:"quantity"`
	DateCreated string  `json:"dateCreated"`
	DateUpdated string  `json:"dateUpdated"`
}

Product represents an individual product.

Jump to

Keyboard shortcuts

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