Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDefaultType = ValidationError{Err: errors.New("type is default")}
View Source
var ErrLinkedToActionType = ValidationError{Err: errors.New("type is linked to action")}
View Source
var ErrLinkedTypeToException = ValidationError{Err: errors.New("type is linked to exception")}
View Source
var ErrLinkedTypeToPbehavior = ValidationError{Err: errors.New("type is linked to pbehavior")}
Functions ¶
This section is empty.
Types ¶
type API ¶
func NewApi ¶
func NewApi( transformer ModelTransformer, store Store, computeChan chan<- []string, actionLogger logger.ActionLogger, logger zerolog.Logger, ) API
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{}
func (AggregationResult) GetTotal ¶
func (r AggregationResult) GetTotal() int64
type CreateRequest ¶
type CreateRequest struct { EditRequest ID string `json:"_id" binding:"id"` IconName string `json:"icon_name" binding:"required,max=255"` }
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,oneof=active inactive maintenance pause"` Priority int64 `json:"priority" binding:"required,min=1"` Color string `json:"color" binding:"required,iscolor"` Hidden *bool `json:"hidden,omitempty"` }
type ListRequest ¶
type ListRequest struct { pagination.FilteredQuery OnlyDefault bool `form:"default"` WithHidden bool `form:"with_hidden"` SortBy string `form:"sort_by" json:"sort_by" binding:"oneoforempty=name priority"` Types []string `form:"types[]" json:"types"` }
type ModelTransformer ¶
type ModelTransformer interface { TransformCreateRequestToModel(request CreateRequest) *Type TransformUpdateRequestToModel(request UpdateRequest) *Type }
func NewModelTransformer ¶
func NewModelTransformer() ModelTransformer
type PriorityResponse ¶
type PriorityResponse struct {
Priority int64 `json:"priority"`
}
type Store ¶
type Store interface { Insert(ctx context.Context, model *Type) error Find(ctx context.Context, r ListRequest) (*AggregationResult, error) GetOneBy(ctx context.Context, id string) (*Type, error) Update(ctx context.Context, id string, model *Type) (bool, error) Delete(ctx context.Context, id string) (bool, error) GetNextPriority(ctx context.Context) (int64, error) }
Store is an interface for pbehavior types storage
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 int64 `bson:"priority" json:"priority"` IconName string `bson:"icon_name" json:"icon_name"` Color string `bson:"color" json:"color"` Default *bool `bson:"default,omitempty" json:"default,omitempty"` Deletable *bool `bson:"deletable,omitempty" json:"deletable,omitempty"` // Hidden is used in API to hide documents from the list response Hidden *bool `bson:"hidden,omitempty" json:"hidden,omitempty"` }
type UpdateRequest ¶
type UpdateRequest struct { EditRequest ID string `json:"-"` IconName string `json:"icon_name" binding:"max=255"` }
type ValidationError ¶
type ValidationError struct {
Err error
}
func (ValidationError) Error ¶
func (e ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.