service

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultPageLimit = 10
View Source
const MaxPageLimit = 500

Variables

This section is empty.

Functions

func RegisterGroupRoute

func RegisterGroupRoute[T, U any](group *gin.RouterGroup, source string, s RestfulService[T, U])

Types

type BaseCreateRequest

type BaseCreateRequest[T any] struct {
	Data T `json:"data"`
}

func (BaseCreateRequest[T]) MakeCreate

func (b BaseCreateRequest[T]) MakeCreate() (*T, error)

type BasePageRequest

type BasePageRequest struct {
	mapper.Paginator
}

func (BasePageRequest) MakePage

func (b BasePageRequest) MakePage() mapper.Paginator

func (BasePageRequest) MakeWrapper

func (b BasePageRequest) MakeWrapper() func(*gorm.DB) *gorm.DB

type BaseRestfulService

type BaseRestfulService[T any] interface {
	RestfulService[T, mapper.PageRes[T]]
}

func NewBaseService

func NewBaseService[T any, U CreateRequest[T], V PageRequest, W UpdateRequest](mapper mapper.BaseMapper[T]) BaseRestfulService[T]

NewBaseService new base restful service

type BaseUpdateRequest

type BaseUpdateRequest struct {
	Data map[string]interface{} `json:"data"`
}

func (BaseUpdateRequest) MakeUpdate

func (b BaseUpdateRequest) MakeUpdate() (map[string]interface{}, error)

type CreateRequest

type CreateRequest[T any] interface {
	MakeCreate() (*T, error)
}

type PageRequest

type PageRequest interface {
	MakePage() mapper.Paginator
	MakeWrapper() func(*gorm.DB) *gorm.DB
}

type RestfulService

type RestfulService[T, U any] interface {
	Create(ctx *gin.Context) error
	Paginate(ctx *gin.Context) (*U, error)
	Retrieve(ctx *gin.Context) (*T, error)
	Update(ctx *gin.Context) error
	Delete(ctx *gin.Context) error
}

type UpdateRequest

type UpdateRequest interface {
	MakeUpdate() (map[string]interface{}, error)
}

Jump to

Keyboard shortcuts

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