pbehaviortype

package
v0.0.0-...-d841f61 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDefaultType = ValidationError(errors.New("type is default"))
View Source
var ErrLinkedToActionType = ValidationError(errors.New("type is linked to action"))
View Source
var ErrLinkedTypeToException = ValidationError(errors.New("type is linked to exception"))
View Source
var ErrLinkedTypeToPbehavior = ValidationError(errors.New("type is linked to pbehavior"))
View Source
var ErrorDuplicatePriority = ValidationError(errors.New("duplicate priority value"))

Functions

func NewApi

func NewApi(
	transformer ModelTransformer,
	store Store,
	computeChan chan<- pbehavior.ComputeTask,
	actionLogger logger.ActionLogger,
	logger zerolog.Logger,
) common.CrudAPI

func ValidateEditRequest

func ValidateEditRequest(sl validator.StructLevel)

Types

type AggregationResult

type AggregationResult struct {
	Data       []Type `bson:"data" json:"data"`
	TotalCount int64  `bson:"total_count" json:"total_count"`
}

func (AggregationResult) GetData

func (r AggregationResult) GetData() interface{}

GetData implementation PaginatedData interface

func (AggregationResult) GetTotal

func (r AggregationResult) GetTotal() int64

GetTotal implementation PaginatedData interface

type CreateRequest

type CreateRequest struct {
	EditRequest
	ID string `json:"_id" binding:"id"`
}

type EditRequest

type EditRequest struct {
	Name        string `json:"name" binding:"required,max=255"`
	Description string `json:"description" binding:"required,max=255"`
	Type        string `json:"type" binding:"required"`
	Priority    *int   `json:"priority" binding:"required"`
	IconName    string `json:"icon_name" binding:"required,max=255"`
	Color       string `json:"color"`
}

type ListRequest

type ListRequest struct {
	pagination.FilteredQuery
	OnlyDefault bool   `form:"default"`
	SortBy      string `form:"sort_by" json:"sort_by" binding:"oneoforempty=name priority"`
}

type ModelTransformer

type ModelTransformer interface {
	TransformCreateRequestToModel(request CreateRequest) *Type
	TransformUpdateRequestToModel(request UpdateRequest) *Type
}

func NewModelTransformer

func NewModelTransformer() ModelTransformer

type Store

type Store interface {
	Insert(model *Type) error
	Find(r ListRequest) (*AggregationResult, error)
	GetOneBy(id string) (*Type, error)
	Update(id string, model *Type) (bool, error)
	Delete(id string) (bool, error)
}

Store is an interface for pbhavior types storage

func NewStore

func NewStore(db mongo.DbClient) Store

NewStore instantiates pbehavior type store.

type Type

type Type struct {
	ID          string `bson:"_id,omitempty" json:"_id"`
	Name        string `bson:"name" json:"name"`
	Description string `bson:"description" json:"description"`
	Type        string `bson:"type" json:"type"`
	Priority    int    `bson:"priority" json:"priority"`
	IconName    string `bson:"icon_name" json:"icon_name"`
	Color       string `bson:"color,omitempty" json:"color,omitempty"`
	Editable    *bool  `bson:"editable,omitempty" json:"editable,omitempty"`
	Deletable   *bool  `bson:"deletable,omitempty" json:"deletable,omitempty"`
}

type UpdateRequest

type UpdateRequest struct {
	EditRequest
	ID string `json:"-"`
}

type ValidationError

type ValidationError error

Jump to

Keyboard shortcuts

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