pbehaviorexception

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 ErrLinkedException = errors.New("exception is linked with pbehavior")
View Source
var ErrTypeNotExists = errors.New("type doesn't exist")

Functions

func NewApi

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

func ValidateExdateRequest

func ValidateExdateRequest(sl validator.StructLevel)

Types

type AggregationResult

type AggregationResult struct {
	Data       []Exception `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 Exception

type Exception struct {
	ID          string        `bson:"_id" json:"_id"`
	Name        string        `bson:"name" json:"name"`
	Description string        `bson:"description" json:"description"`
	Exdates     []Exdate      `bson:"exdates" json:"exdates"`
	Created     types.CpsTime `bson:"created" json:"created" swaggertype:"integer"`
	Deletable   *bool         `bson:"deletable,omitempty" json:"deletable,omitempty"`
}

type Exdate

type Exdate struct {
	Begin types.CpsTime  `bson:"begin" json:"begin" swaggertype:"integer"`
	End   types.CpsTime  `bson:"end" json:"end" swaggertype:"integer"`
	Type  pbehavior.Type `bson:"type" json:"type"`
}

type ExdateRequest

type ExdateRequest struct {
	Begin types.CpsTime `json:"begin" binding:"required" swaggertype:"integer"`
	End   types.CpsTime `json:"end" binding:"required" swaggertype:"integer"`
	Type  string        `json:"type" binding:"required"`
}

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) (*Exception, error)
	TransformUpdateRequestToModel(request UpdateRequest) (*Exception, error)
	TransformExdatesRequestToModel(request []ExdateRequest) ([]Exdate, error)
}

func NewModelTransformer

func NewModelTransformer(dbClient mongo.DbClient) ModelTransformer

type Request

type Request struct {
	Name        string          `json:"name" binding:"required,max=255"`
	Description string          `json:"description" binding:"required,max=255"`
	Exdates     []ExdateRequest `json:"exdates" binding:"required,notblank,dive"`
}

type Store

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

func NewStore

func NewStore(dbClient mongo.DbClient) Store

type UpdateRequest

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

Jump to

Keyboard shortcuts

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