action

package
v0.0.0-...-ca6517d Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetActionLabel

func GetActionLabel(name string) string

Types

type ActionCallFun

type ActionCallFun[T any] func(ctx context.Context, data *T) error

type ActionCallParamsFun

type ActionCallParamsFun[T any] func(ctx context.Context, data *T, params *gjson.Result) error

type FormatFun

type FormatFun[T any] func(model *T, data *gjson.Result, e echo.Context) error

type InitFun

type InitFun[T any] func(t *Resources[T], e echo.Context) error

type ManyCallFun

type ManyCallFun[T any] func(data []T, params *gjson.Result, ctx echo.Context) []T

type MetaManyFun

type MetaManyFun[T any] func(orm *gorm.DB, data []T, e echo.Context)

type MetaOneFun

type MetaOneFun[T any] func(data T, e echo.Context)

type OneCallFun

type OneCallFun[T any] func(data T, params *gjson.Result, ctx echo.Context) T

type Pagination

type Pagination struct {
	Status   bool
	PageSize int
}

type QueryFun

type QueryFun func(tx *gorm.DB, e echo.Context) *gorm.DB

type QueryRequestFun

type QueryRequestFun func(tx *gorm.DB, params *gjson.Result, e echo.Context) *gorm.DB

type Resources

type Resources[T any] struct {
	Model        T
	Key          string
	Tree         bool
	Pagination   Pagination
	IncludesMany []string
	ExcludesMany []string
	IncludesOne  []string
	ExcludesOne  []string

	TransformFun TransformFun[T]

	ActionList       bool
	ActionShow       bool
	ActionCreate     bool
	ActionEdit       bool
	ActionDelete     bool
	ActionStore      bool
	ActionSoftDelete bool
	Extend           map[string]any
	// contains filtered or unexported fields
}

func New

func New[T any](model T) *Resources[T]

func (*Resources[T]) Create

func (t *Resources[T]) Create(ctx echo.Context) error

func (*Resources[T]) CreateAfter

func (t *Resources[T]) CreateAfter(call ActionCallParamsFun[T])

func (*Resources[T]) CreateBefore

func (t *Resources[T]) CreateBefore(call ActionCallParamsFun[T])

func (*Resources[T]) Delete

func (t *Resources[T]) Delete(ctx echo.Context) error

func (*Resources[T]) DeleteAfter

func (t *Resources[T]) DeleteAfter(call ActionCallFun[T])

func (*Resources[T]) DeleteBefore

func (t *Resources[T]) DeleteBefore(call ActionCallFun[T])

func (*Resources[T]) DeleteMany

func (t *Resources[T]) DeleteMany(ctx echo.Context) error

func (*Resources[T]) Edit

func (t *Resources[T]) Edit(ctx echo.Context) error

func (*Resources[T]) EditAfter

func (t *Resources[T]) EditAfter(call ActionCallParamsFun[T])

func (*Resources[T]) EditBefore

func (t *Resources[T]) EditBefore(call ActionCallParamsFun[T])

func (*Resources[T]) Format

func (t *Resources[T]) Format(call FormatFun[T])

Format 数据格式化

func (*Resources[T]) Init

func (t *Resources[T]) Init(call InitFun[T])

Init 初始化回调

func (*Resources[T]) List

func (t *Resources[T]) List(ctx echo.Context) error

func (*Resources[T]) ManyAfter

func (t *Resources[T]) ManyAfter(call ManyCallFun[T])

func (*Resources[T]) MetaMany

func (t *Resources[T]) MetaMany(call MetaManyFun[T])

MetaMany 多条元数据

func (*Resources[T]) MetaOne

func (t *Resources[T]) MetaOne(call MetaManyFun[T])

MetaOne 单条元数据

func (*Resources[T]) OneAfter

func (t *Resources[T]) OneAfter(call OneCallFun[T])

func (*Resources[T]) Query

func (t *Resources[T]) Query(call QueryFun)

Query 通用查询

func (*Resources[T]) QueryMany

func (t *Resources[T]) QueryMany(call QueryRequestFun)

QueryMany 多条数据查询

func (*Resources[T]) QueryOne

func (t *Resources[T]) QueryOne(call QueryRequestFun)

QueryOne 单条数据查询

func (*Resources[T]) QueryParams

func (t *Resources[T]) QueryParams(data any)

func (*Resources[T]) Restore

func (t *Resources[T]) Restore(ctx echo.Context) error

func (*Resources[T]) RestoreAfter

func (t *Resources[T]) RestoreAfter(call ActionCallFun[T])

func (*Resources[T]) RestoreBefore

func (t *Resources[T]) RestoreBefore(call ActionCallFun[T])

func (*Resources[T]) RestoreMany

func (t *Resources[T]) RestoreMany(ctx echo.Context) error

func (*Resources[T]) Result

func (t *Resources[T]) Result() Result

func (*Resources[T]) SaveAfter

func (t *Resources[T]) SaveAfter(call ActionCallParamsFun[T])

func (*Resources[T]) SaveBefore

func (t *Resources[T]) SaveBefore(call ActionCallParamsFun[T])

func (*Resources[T]) Show

func (t *Resources[T]) Show(ctx echo.Context) error

func (*Resources[T]) Store

func (t *Resources[T]) Store(ctx echo.Context) error

func (*Resources[T]) StoreAfter

func (t *Resources[T]) StoreAfter(call ActionCallParamsFun[T])

func (*Resources[T]) StoreBefore

func (t *Resources[T]) StoreBefore(call ActionCallParamsFun[T])

func (*Resources[T]) Transform

func (t *Resources[T]) Transform(call TransformFun[T])

Transform 字段转换

func (*Resources[T]) Trash

func (t *Resources[T]) Trash(ctx echo.Context) error

func (*Resources[T]) TrashAfter

func (t *Resources[T]) TrashAfter(call ActionCallFun[T])

func (*Resources[T]) TrashBefore

func (t *Resources[T]) TrashBefore(call ActionCallFun[T])

func (*Resources[T]) TrashMany

func (t *Resources[T]) TrashMany(ctx echo.Context) error

func (*Resources[T]) Validator

func (t *Resources[T]) Validator(call ValidatorFun)

Validator 数据验证 Docs github.com/go-playground/validator/v10

type Result

type Result map[string]func(ctx echo.Context) error

type TransformFun

type TransformFun[T any] func(item *T, index int) map[string]any

type ValidatorFun

type ValidatorFun func(data *gjson.Result, e echo.Context) (validator.ValidatorRule, error)

Jump to

Keyboard shortcuts

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