service

package
v0.0.60 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFoundService   = errors.New("no service instant matches the give Model interface, skip processing service layer")
	ErrNotFoundServiceId = errors.New("not found service id in assetIdMap")
)

Functions

func GinContext

func GinContext(c *gin.Context) *types.ServiceContext

GinContext build *types.ServiceContext from *gin.Context.

func Init

func Init() error

func Register

func Register[S types.Service[M], M types.Model](s ...S)

Register service instance into serviceMap. pass parameters to replace the default service instance. If the passed parameters is nil, skip replace.

Types

type Base

type Base[M types.Model] struct{ types.Logger }

func (Base[M]) CreateAfter

func (Base[M]) CreateAfter(*types.ServiceContext, ...M) error

func (Base[M]) CreateBefore

func (Base[M]) CreateBefore(*types.ServiceContext, ...M) error

func (Base[M]) DeleteAfter

func (Base[M]) DeleteAfter(*types.ServiceContext, ...M) error

func (Base[M]) DeleteBefore

func (Base[M]) DeleteBefore(*types.ServiceContext, ...M) error

func (Base[M]) Export

func (Base[M]) Export(*types.ServiceContext, ...M) ([]byte, error)

func (Base[M]) Filter

func (Base[M]) Filter(_ *types.ServiceContext, m M) M

func (Base[M]) FilterRaw

func (Base[M]) FilterRaw(_ *types.ServiceContext) string

func (Base[M]) GetAfter

func (Base[M]) GetAfter(*types.ServiceContext, ...M) error

func (Base[M]) GetBefore

func (Base[M]) GetBefore(*types.ServiceContext, ...M) error

func (Base[M]) Import

func (Base[M]) Import(*types.ServiceContext, io.Reader) ([]M, error)

func (Base[M]) ListAfter

func (Base[M]) ListAfter(*types.ServiceContext, *[]M) error

func (Base[M]) ListBefore

func (Base[M]) ListBefore(*types.ServiceContext, *[]M) error

func (Base[M]) UpdateAfter

func (Base[M]) UpdateAfter(*types.ServiceContext, ...M) error

func (Base[M]) UpdateBefore

func (Base[M]) UpdateBefore(*types.ServiceContext, ...M) error

func (Base[M]) UpdatePartialAfter

func (Base[M]) UpdatePartialAfter(*types.ServiceContext, ...M) error

func (Base[M]) UpdatePartialBefore

func (Base[M]) UpdatePartialBefore(*types.ServiceContext, ...M) error

type Factory

type Factory[M types.Model] struct{}

Factory is a service factory used to product service instance. The servicei instance should registered by function `register()` in init()

The service defined by user should be unexported (structure name is lowercase). service instance are only returns by the `Factory`.

func (Factory[M]) Service

func (f Factory[M]) Service() types.Service[M]

Jump to

Keyboard shortcuts

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