tranapp

package
v0.0.0-...-7774a9f Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: Apache-2.0 Imports: 21 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

func Routes

func Routes(app *web.App, cfg Config)

Routes adds specific routes for this group.

Types

type Config

type Config struct {
	Log        *logger.Logger
	DB         *sqlx.DB
	UserBus    *userbus.Business
	ProductBus *productbus.Business
	AuthClient *authclient.Client
}

Config contains all the mandatory systems required by handlers.

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.

func (*NewTran) Decode

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

Decode implements the decoder interface.

func (NewTran) Validate

func (app NewTran) Validate() error

Validate checks the data in the model is considered clean.

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.

func (Product) Encode

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

Encode implements the encoder interface.

Jump to

Keyboard shortcuts

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