pbehaviorexception

package
v0.0.0-...-9b5cd94 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: AGPL-3.0 Imports: 25 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

This section is empty.

Types

type API

type API interface {
	common.CrudAPI
	Import(c *gin.Context)
}

func NewApi

func NewApi(
	transformer ModelTransformer,
	store Store,
	computeChan chan<- []string,
	actionLogger logger.ActionLogger,
	logger zerolog.Logger,
) API

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     datetime.CpsTime `bson:"created" json:"created" swaggertype:"integer"`
	Deletable   *bool            `bson:"deletable,omitempty" json:"deletable,omitempty"`
}

type Exdate

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

type ExdateRequest

type ExdateRequest struct {
	exdate.Request
	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(ctx context.Context, request CreateRequest) (*Exception, error)
	TransformUpdateRequestToModel(ctx context.Context, request UpdateRequest) (*Exception, error)
	TransformExdatesRequestToModel(ctx context.Context, 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(ctx context.Context, model *Exception) error
	Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
	GetOneById(ctx context.Context, id string) (*Exception, error)
	Update(ctx context.Context, model *Exception) (bool, error)
	Delete(ctx context.Context, id string) (bool, error)
	IsLinked(ctx context.Context, id string) (bool, error)
	Import(ctx context.Context, name, pbhType string, f multipart.File, fh *multipart.FileHeader) (*Exception, error)
}

func NewStore

func NewStore(dbClient mongo.DbClient, timezoneConfigProvider config.TimezoneConfigProvider) 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