actions

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2023 License: MIT Imports: 23 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BsonMTransferModel

func BsonMTransferModel(bm bson.M, model any) error

BsonMTransferModel bson.M to model

Types

type Base

type Base struct {
	ModelMgm  mgm.Model
	ModelGorm schema.Tabler
}

Base action

func (*Base) Handler

func (*Base) Handler() gin.HandlerFunc

Handler action handler

func (*Base) String

func (*Base) String() string

String string

type Control

type Control struct {
	Base
	Key string
}

Control action

func NewControlGorm

func NewControlGorm(m schema.Tabler, key string) *Control

NewControlGorm new control action

func NewControlMgm

func NewControlMgm(m mgm.Model, key string) *Control

NewControlMgm new control action

func (*Control) Handler

func (e *Control) Handler() gin.HandlerFunc

Handler action handler

func (*Control) String

func (*Control) String() string

String action name

type Delete

type Delete struct {
	Base
	Key string
}

Delete action

func NewDeleteGorm

func NewDeleteGorm(m schema.Tabler, key string) *Delete

NewDeleteGorm new delete action

func NewDeleteMgm

func NewDeleteMgm(m mgm.Model, key string) *Delete

NewDeleteMgm new deleteMgm action

func (*Delete) Handler

func (e *Delete) Handler() gin.HandlerFunc

Handler action handler

func (*Delete) String

func (*Delete) String() string

String action name

type Get

type Get struct {
	Base
	Key string
}

Get action

func NewGetGorm

func NewGetGorm(m schema.Tabler, key string) *Get

NewGetGorm new get action

func NewGetMgm

func NewGetMgm(m mgm.Model, key string) *Get

NewGetMgm new get action

func (*Get) Handler

func (e *Get) Handler() gin.HandlerFunc

Handler action handler

func (*Get) String

func (*Get) String() string

String action name

type LinkConfig

type LinkConfig struct {
	// FieldName field name
	FieldName string
	// CollectionName collection name
	CollectionName string
	// LocalField local field
	LocalField string
	// ForeignField foreign field
	ForeignField string
}

LinkConfig link config

type Model

type Model interface {
	mgm.Model
	schema.Tabler
}

Model gorm and mgm model

type ModelGorm

type ModelGorm struct {
	// ID primary key
	ID string `gorm:"primarykey" json:"id" bson:"_id,omitempty" form:"id" query:"id"`
	// CreatedAt create time
	CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
	// UpdatedAt update time
	UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`
	// DeletedAt delete time soft delete
	DeletedAt gorm.DeletedAt `gorm:"index" bson:"-" json:"-"`
}

ModelGorm model gorm

func (*ModelGorm) GetID

func (e *ModelGorm) GetID() any

GetID get id

func (*ModelGorm) PrepareID

func (e *ModelGorm) PrepareID(_ any) (any, error)

PrepareID prepare id

func (*ModelGorm) SetID

func (e *ModelGorm) SetID(id any)

SetID set id

func (*ModelGorm) TableName

func (e *ModelGorm) TableName() string

TableName return table name

type ModelProvider

type ModelProvider string

ModelProvider model provider

const (
	// ModelProviderMgm mgm model provider
	ModelProviderMgm ModelProvider = "mgm"
	// ModelProviderGorm gorm model provider
	ModelProviderGorm ModelProvider = "gorm"
)

type Pagination

type Pagination struct {
	Page     int64 `form:"page" query:"page"`
	PageSize int64 `form:"pageSize" query:"pageSize"`
}

Pagination pagination params

func (*Pagination) GetPage

func (e *Pagination) GetPage() int64

GetPage get page

func (*Pagination) GetPageSize

func (e *Pagination) GetPageSize() int64

GetPageSize get page size

type Search struct {
	Base
	Search response.Searcher
}

Search action

func NewSearchGorm

func NewSearchGorm(m Model, search response.Searcher) *Search

NewSearchGorm new search action

func NewSearchMgm

func NewSearchMgm(m mgm.Model, search response.Searcher) *Search

NewSearchMgm new search action

func (*Search) Handler

func (e *Search) Handler() gin.HandlerFunc

Handler action handler

func (*Search) String

func (*Search) String() string

String action name

Jump to

Keyboard shortcuts

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