service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHandler

func RegisterHandler[T any](api router.Party, service Service[T])

Types

type Engine

type Engine[T any] interface {
	GenerateCreateParameters() (interface{}, error)
	GenerateUpdateParameters() (interface{}, error)
	GenerateFilterParameters() (interface{}, error)
	FillModelFromCreateParameters(createParams interface{}) (*T, error)
	UpdateModelFromUpdateParameters(model *T, updateParams interface{}) (*T, error)
}

func CreateEngine

func CreateEngine[M any]() Engine[M]

type Service

type Service[T any] interface {
	// GetByID retrieves a model instance by its identifier.
	GetByID(ctx iris.Context)
	// GetAll returns all model instances.
	GetAll(ctx iris.Context)
	// Create inserts a new model instance into the database.
	Create(ctx iris.Context)
	// UpdatePatch modifies an existing model instance in the database.
	UpdatePatch(ctx iris.Context)
	// Delete removes a model instance identified by id.
	Delete(ctx iris.Context)
}

Service is a generic interface that wraps repository operations and provides additional helper functions for extracting payloads (create, update, filter) from a model instance.

func NewModelService

func NewModelService[T any](eng Engine[T], repo repository.Repository[T]) Service[T]

Jump to

Keyboard shortcuts

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