domain

package
v0.0.0-...-3e80ac3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataDomain

type DataDomain interface {
	GetResource() string
	GetRoutePath() string
}

type DataRepository

type DataRepository[T GenericResource] interface {
	List(ctx context.Context, offset, limit int) (items []T, total int, err error)
	Search(ctx context.Context, text string, offset, limit int) (items []T, total int, err error)
	GetByID(ctx context.Context, id int) (item T, err error)
	Create(ctx context.Context, body T) (item T, err error)
	Update(ctx context.Context, body T) (err error)
	Delete(ctx context.Context, id int) (err error)
}

type DataService

type DataService[T GenericResource] interface {
	List(ctx context.Context, offset, limit int) (data *Pagination[T], err error)
	Search(ctx context.Context, text string, offset, limit int) (data *Pagination[T], err error)
	GetByID(ctx context.Context, id int) (item T, err error)
	Create(ctx context.Context, body T) (item T, err error)
	Update(ctx context.Context, body T) (err error)
	Delete(ctx context.Context, id int) (err error)
}

type GenericResource

type GenericResource interface {
	DataDomain
}

type Pagination

type Pagination[T any] struct {
	Results []T `json:"results"`
	Total   int `json:"total"`
	Limit   int `json:"limit"`
	Offset  int `json:"offset"`
}

type Product

type Product struct {
	ID          int    `json:"id"`
	Description string `json:"description"`
	Price       string `json:"price"`
	Name        string `json:"name"`
}

type ProductResource

type ProductResource Product

func (*ProductResource) GetResource

func (item *ProductResource) GetResource() string

func (*ProductResource) GetRoutePath

func (item *ProductResource) GetRoutePath() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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