actions

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 20 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateFile

type CreateFile struct {
	Key         string
	ContentType string
	File        io.ReadCloser
}

type CreateModelElement

type CreateModelElement struct {
	ModelCode    string         `validate:"required"`
	ModelElement map[string]any `validate:"required"`
}

type DeleteModelElement

type DeleteModelElement struct {
	ModelCode string `json:"modelCode" validate:"required"`
	PKey      any    `json:"pKey" validate:"required,notBlank"`
}

type DeleteModelElements

type DeleteModelElements struct {
	ModelCode string `json:"modelCode" validate:"required"`
	PKeys     []any  `json:"pKeys" validate:"required,unique"`
}

type EditView

type EditView struct {
	FormFields []FormField `json:"formFields"`
	Validation any         `json:"validation"`
}

type Export

type Export struct {
	// contains filtered or unexported fields
}

func NewExport

func NewExport(
	repository ExportInfoRepository,
	modelsRegistry ModelsRegistry,
	exporter Exporter,
	fileStorage FileStorage,
	logger *zap.SugaredLogger,
	fileStorageBaseEndpoint string,
) *Export

func (Export) Export

func (s Export) Export(ctx context.Context, action ExportModelElements) error

func (Export) GetExportInfo

func (s Export) GetExportInfo(ctx context.Context, action GetExportInfo) (any, error)

type ExportInfoRepository

type ExportInfoRepository interface {
	GetLast(ctx context.Context, code string) (*entity.ExportInfo, error)
	Create(ctx context.Context, export entity.ExportInfo) error
	Update(ctx context.Context, export entity.ExportInfo) error
	Delete(ctx context.Context, id uuid.UUID) (string, error)
}

type ExportModelElements

type ExportModelElements struct {
	ModelCode string       `json:"modelCode" validate:"required"`
	Filter    FieldsFilter `json:"filter"`
	OrderBy
}

type Exporter

type Exporter interface {
	GetFile(ctx context.Context, model *focus.Model, filter ListModelElementsQuery) (*os.File, error)
}

type FieldValuesList

type FieldValuesList struct {
	Items any   `json:"items"`
	Total int64 `json:"total"`
}

type FieldsFilter

type FieldsFilter map[string][]any

type FileStorage

type FileStorage interface {
	Upload(ctx context.Context, media *CreateFile) error
	Delete(ctx context.Context, keys ...string) error
	GetSize(ctx context.Context, key string) (int64, error)
}

type FormField

type FormField struct {
	Code      string         `json:"code"`
	Title     string         `json:"name"`
	Type      form.FieldType `json:"type"`
	Multiple  bool           `json:"multiple"`
	Sortable  bool           `json:"sortable"`
	Block     string         `json:"block,omitempty"`
	Extra     map[string]any `json:"extra,omitempty"`
	Hidden    bool           `json:"hidden,omitempty"`
	Disabled  bool           `json:"disabled,omitempty"`
	Step      float64        `json:"step,omitempty"`
	Precision int            `json:"precision,omitempty"`
}

type FormView

type FormView struct {
	FormFields []FormField `json:"formFields"`
}

type GetExportInfo

type GetExportInfo struct {
	ModelCode string
}

type GetModel

type GetModel struct {
	ModelCode string `json:"modelCode" validate:"required"`
}

type GetModelElement

type GetModelElement struct {
	ModelCode string `json:"modelCode" validate:"required,notBlank"`
	PKey      any    `json:"PKey" validate:"required,notBlank"`
}

type List

type List struct {
	Items []map[string]any `json:"items"`
	Total int64            `json:"total"`
}

type ListField

type ListField struct {
	Code     string `json:"code"`
	Title    string `json:"name"`
	Sortable bool   `json:"sortable"`
	IsTime   bool   `json:"isTime"`
}

type ListFieldValues

type ListFieldValues struct {
	ModelCode string `json:"modelCode" validate:"required"`
	FieldCode string `json:"fieldCode" validate:"required"`
	Query     string `json:"query"`
	Pagination
}

type ListModelElements

type ListModelElements struct {
	ModelCode string       `json:"-"`
	Filter    FieldsFilter `json:"filter"`
	ModelElementsQueryFilter
	Pagination
	OrderBy
}

type ListModelElementsQuery

type ListModelElementsQuery struct {
	ModelCode    string              `json:"-"`
	Filter       ModelElementsFilter `json:"filter"`
	SelectFields []string            `json:"-"`
	Pagination   `json:"-"`
	OrderBy      `json:"-"`
}

type ListModels

type ListModels struct {
	Pagination
	ModelOrderBy
}

type ListView

type ListView struct {
	Fields []ListField `json:"fields"`
}

type MediaService

type MediaService interface {
	CheckIds(ctx context.Context, ids ...uuid.UUID) error
}

type ModelDescription

type ModelDescription struct {
	Code           string     `json:"code"`           // Уникальный код модели
	Title          string     `json:"name"`           // Название модели
	IdentifierCode string     `json:"identifierCode"` // Код поля, которое является идентификатором модели
	Views          ModelViews `json:"views"`          // Параметры отображения полей модели
}

type ModelElements

type ModelElements struct {
	// contains filtered or unexported fields
}

func NewModelElements

func NewModelElements(
	modelsRegistry ModelsRegistry,
	repositoryResolver RepositoryResolver,
	mediaService MediaService,
	validator Validator,
	callbacks map[string]callbacks.Callbacks,
) *ModelElements

func (ModelElements) Create

func (s ModelElements) Create(ctx context.Context, action CreateModelElement) (pkey any, err error)

Create создание нового элемента модели.

func (ModelElements) Delete

func (s ModelElements) Delete(ctx context.Context, action DeleteModelElement) error

Delete удаление одного элемента модели.

func (ModelElements) DeleteList

func (s ModelElements) DeleteList(ctx context.Context, action DeleteModelElements) error

DeleteList удаление нескольких элементов модели.

func (ModelElements) Get

func (s ModelElements) Get(ctx context.Context, action GetModelElement) (map[string]any, error)

Get получение элемента модели по первичному ключу.

func (ModelElements) List

func (s ModelElements) List(ctx context.Context, action ListModelElements) (*List, error)

List получение списка элементов модели.

func (ModelElements) Update

func (s ModelElements) Update(ctx context.Context, action UpdateModelElement) error

Update обновление элемента модели.

type ModelElementsFilter

type ModelElementsFilter struct {
	FieldsFilter FieldsFilter             `json:"fieldsFilter"`
	QueryFilter  ModelElementsQueryFilter `json:"query"`
}

type ModelElementsQueryFilter

type ModelElementsQueryFilter struct {
	FieldsCodes []string `json:"fields" validate:"required_with=Query"`
	Query       string   `json:"query"`
}

type ModelOrderBy

type ModelOrderBy struct {
	Sort  string `json:"sort" validate:"omitempty,oneof=code name"`
	Order string `json:"order" validate:"omitempty,oneof=asc desc"`
}

type ModelShort

type ModelShort struct {
	Code  string `json:"code"` // Уникальный код модели
	Title string `json:"name"` // Название модели
}

type ModelViews

type ModelViews struct {
	Create EditView `json:"create"`
	Update EditView `json:"update"`
	Filter FormView `json:"filter"`
	List   ListView `json:"list"`
}

ModelViews описывает параметры отображения полей модели

type Models

type Models struct {
	// contains filtered or unexported fields
}

Models сервис работы с моделями

func NewModels

func NewModels(
	modelsRegistry ModelsRegistry,
	repositoryResolver RepositoryResolver,
	selectRequest form.Request,
) *Models

NewModels конструктор

func (Models) Get

func (s Models) Get(_ context.Context, action GetModel) (*ModelDescription, error)

Get получение описания модели

func (Models) List

func (s Models) List(action ListModels) ModelsList

List получение списка моделей

func (Models) ListFieldValues

func (s Models) ListFieldValues(ctx context.Context, action ListFieldValues) (*FieldValuesList, error)

ListFieldValues получение значений поля модели

type ModelsList

type ModelsList struct {
	Items []ModelShort `json:"items"`
	Total int          `json:"total"`
}

type ModelsRegistry

type ModelsRegistry interface {
	GetModel(code string) *focus.Model
	ListModels() []*focus.Model
}

type OrderBy

type OrderBy struct {
	Sort  string `json:"sort"`
	Order string `json:"order" validate:"omitempty,oneof=asc desc"`
}

type Pagination

type Pagination struct {
	Offset int `json:"offset" validate:"min=0"`
	Limit  int `json:"limit" validate:"required,min=1,max=100"`
}

type Repository

type Repository interface {
	Has(ctx context.Context, pk any) (bool, error)
	Create(ctx context.Context, elem any) (id any, err error)
	Get(ctx context.Context, key any) (elem any, err error)
	Update(ctx context.Context, elem any) error
	Count(ctx context.Context, filter ModelElementsFilter) (count int64, err error)
	List(ctx context.Context, filter ListModelElementsQuery) (elems []any, err error)
	ListFieldValues(ctx context.Context, action ListFieldValues) (fieldValues any, err error)
	CountFieldValues(ctx context.Context, code string, query string) (count int64, err error)
	Delete(ctx context.Context, pks ...any) error
}

type RepositoryResolver

type RepositoryResolver interface {
	Resolve(modelCode string) Repository
}

type Select

type Select []string

type UpdateModelElement

type UpdateModelElement struct {
	ModelCode    string         `validate:"required"`
	PKey         any            `validate:"required"`
	ModelElement map[string]any `validate:"required"`
}

type Validator

type Validator interface {
	Validate(ctx context.Context, value any) error
	ValidatePartial(ctx context.Context, value any) error
}

Jump to

Keyboard shortcuts

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