views

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenericAPIView

func GenericAPIView(viewAPI ViewGenericAPIInterface) map[ViewSetMethod]func(*appctx.AppContext)

func GenericCreate

func GenericCreate(view ViewInterface, queryset *gorm.DB, data serializers.SerializerModels, appCtx *appctx.AppContext, middle *BringMind)

func GenericDelete

func GenericDelete(view ViewInterface, queryset *gorm.DB, data serializers.SerializerModels, appCtx *appctx.AppContext, middle *BringMind)

func GenericList

func GenericList(view ViewInterface, queryset *gorm.DB, data interface{}, appCtx *appctx.AppContext)

func GenericRetrieve

func GenericRetrieve(view ViewInterface, queryset *gorm.DB, data serializers.SerializerModels, appCtx *appctx.AppContext, middle *BringMind)

func GenericUpdate

func GenericUpdate(view ViewInterface, queryset *gorm.DB, data serializers.SerializerModels, appCtx *appctx.AppContext, middle *BringMind)

Types

type BaseView

type BaseView struct {
	Methods           []string
	Parameters        filters.Parameters
	ViewType          ViewType
	FilteredFields    []filters.FilterQuerySet
	SortAllowFields   []filters.FilterQuerySet
	Serializer        serializers.SerializerModels
	Permissions       []permissions.PermissionInterface
	Module            string
	AppContext        *appctx.AppContext
	PreloadFieldsName []string
	Omit              []string
	AppLog            func(*appctx.AppContext, string, string) error
}

func (*BaseView) CheckPermission

func (b *BaseView) CheckPermission(appContext *appctx.AppContext) bool

Permissions

func (*BaseView) CheckPermissionObject

func (b *BaseView) CheckPermissionObject(appContext *appctx.AppContext, model models.BaseModelInterface) bool

func (*BaseView) Create

func (b *BaseView) Create(appCtx *appctx.AppContext)

func (*BaseView) Delete

func (b *BaseView) Delete(appCtx *appctx.AppContext)

func (*BaseView) FilterAndSort

func (b *BaseView) FilterAndSort(tx *gorm.DB, params filters.Parameters) *gorm.DB

func (*BaseView) Get

func (b *BaseView) Get(appCtx *appctx.AppContext)

HTTP METHODS

func (*BaseView) GetFilteredFields

func (b *BaseView) GetFilteredFields() []filters.FilterQuerySet

func (*BaseView) GetID

func (b *BaseView) GetID(r *http.Request) (int, error)

func (*BaseView) GetMethods

func (b *BaseView) GetMethods() []ViewSetMethod

func (*BaseView) GetMiddlewares

func (b *BaseView) GetMiddlewares() []func(http.Handler) http.Handler

func (*BaseView) GetOmit

func (b *BaseView) GetOmit() []string

func (*BaseView) GetPermissionModule

func (b *BaseView) GetPermissionModule() string

func (*BaseView) GetPreloadFieldName

func (b *BaseView) GetPreloadFieldName() []string

func (*BaseView) GetSerializer

func (b *BaseView) GetSerializer() serializers.SerializerModels

func (*BaseView) GetSortAllowFields

func (b *BaseView) GetSortAllowFields() []filters.FilterQuerySet

func (*BaseView) GetViewType

func (b *BaseView) GetViewType() ViewType

func (*BaseView) List

func (b *BaseView) List(appCtx *appctx.AppContext)

VIEWSET METHODS

func (*BaseView) LogSetter

func (b *BaseView) LogSetter(appCtx *appctx.AppContext, diff applog.DiffInterface) error

func (*BaseView) Post

func (b *BaseView) Post(appCtx *appctx.AppContext)

func (*BaseView) Put

func (b *BaseView) Put(appCtx *appctx.AppContext)

func (*BaseView) Retrieve

func (b *BaseView) Retrieve(appCtx *appctx.AppContext)

func (*BaseView) Update

func (b *BaseView) Update(appCtx *appctx.AppContext)

type ViewGenericAPIInterface

type ViewGenericAPIInterface interface {
	ViewInterface
	GetQuerySet(*gorm.DB, *appctx.AppContext) *gorm.DB
	GetSerializerModels() serializers.SerializerModels
	GetSliceSerializerModels() interface{}
	GetOmit() []string
}

type ViewInterface

type ViewInterface interface {
	GetMethods() []ViewSetMethod
	GetMiddlewares() []func(http.Handler) http.Handler
	FilterAndSort(*gorm.DB, filters.Parameters) *gorm.DB
	GetViewType() ViewType
	GetID(r *http.Request) (int, error)
	GetPermissionModule() string

	Get(*appctx.AppContext)
	Post(*appctx.AppContext)
	Put(*appctx.AppContext)

	List(*appctx.AppContext)
	Create(*appctx.AppContext)
	Retrieve(*appctx.AppContext)
	Update(*appctx.AppContext)
	Delete(*appctx.AppContext)

	GetSerializer() serializers.SerializerModels
	CheckPermission(*appctx.AppContext) bool
	CheckPermissionObject(*appctx.AppContext, models.BaseModelInterface) bool
	GetPreloadFieldName() []string
	LogSetter(*appctx.AppContext, applog.DiffInterface) error

	GetFilteredFields() []filters.FilterQuerySet
	GetSortAllowFields() []filters.FilterQuerySet
}

type ViewSetMethod

type ViewSetMethod string
const (
	// Base methods
	GET  ViewSetMethod = "get"
	POST ViewSetMethod = "post"

	// Castom methods
	List     ViewSetMethod = "list"
	Create   ViewSetMethod = "create"
	Update   ViewSetMethod = "update"
	Retrieve ViewSetMethod = "retrieve"
	Delete   ViewSetMethod = "delete"
)

type ViewType

type ViewType string
const (
	// способ отображения данных
	// на данный момент это либо таблица, либо дерево
	Tree  ViewType = "tree"
	Table ViewType = "table"
	File  ViewType = "file"
	Api   ViewType = "api"
)

Jump to

Keyboard shortcuts

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