cityapp

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: 10 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 city domain.

func NewApp

func NewApp(cityBus *citybus.Business) *App

NewApp constructs a city app API for use.

func NewAppWithAuth

func NewAppWithAuth(cityBus *citybus.Business, ath *auth.Auth) *App

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

func (*App) Create

func (a *App) Create(ctx context.Context, app NewCity) (City, error)

Create adds a new city to the system.

func (*App) Delete

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

Delete removes an existing city.

func (*App) Query

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

Query retrieves a list of cities based on the filter, order, and page.

func (*App) QueryByID

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

QueryByID retrieves the city by the specified ID.

func (*App) Update

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

Update updates an existing city.

type City

type City struct {
	ID       string `json:"id"`
	RegionID string `json:"region_id"`
	Name     string `json:"name"`
}

func ToAppCities

func ToAppCities(bus []citybus.City) []City

func ToAppCity

func ToAppCity(bus citybus.City) City

func (City) Encode

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

Encode implements the encoder interface.

type NewCity

type NewCity struct {
	RegionID string `json:"regionID" validate:"required"`
	Name     string `json:"name" validate:"required,min=3,max=100"`
}

NewCity defines the data needed to add a city.

func (*NewCity) Decode

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

Decode implements the decoder interface.

func (NewCity) Validate

func (app NewCity) 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
	RegionID string
	Name     string
}

QueryParams represents the query parameters that can be used.

type UpdateCity

type UpdateCity struct {
	RegionID *string `json:"regionID"`
	Name     *string `json:"name"`
}

UpdateCity defines the data needed to update a city.

func (*UpdateCity) Decode

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

Decode implements the decoder interface.

func (UpdateCity) Validate

func (app UpdateCity) 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