pbehaviorreason

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: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLinkedReasonToAction = ValidationError(errors.New("reason is linked to action"))
View Source
var ErrLinkedReasonToPbehavior = ValidationError(errors.New("reason is linked to pbehavior"))

Functions

func NewApi

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

Types

type AggregationResult

type AggregationResult struct {
	Data       []Reason `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 {
	Request
	ID string `json:"_id" binding:"id"`
}

type ListRequest

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

type ModelTransformer

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

func NewModelTransformer

func NewModelTransformer() ModelTransformer

type Reason

type Reason struct {
	ID          string `bson:"_id" json:"_id"`
	Name        string `bson:"name" json:"name"`
	Description string `bson:"description" json:"description"`
	Deletable   *bool  `bson:"deletable,omitempty" json:"deletable,omitempty"`
}

type Request

type Request struct {
	Name        string `json:"name" binding:"required,max=255"`
	Description string `json:"description" binding:"required,max=255"`
}

type Store

type Store interface {
	Insert(model *Reason) error
	Find(query ListRequest) (*AggregationResult, error)
	GetOneBy(filter bson.M) (*Reason, error)
	Update(model *Reason) (bool, error)
	Delete(id string) (bool, error)
	IsLinkedToPbehavior(id string) (bool, error)
}

func NewStore

func NewStore(dbClient mongo.DbClient) Store

type UpdateRequest

type UpdateRequest struct {
	Request
	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