widgettemplate

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewApi

func NewApi(
	store Store,
	actionLogger logger.ActionLogger,
) common.CrudAPI

func ValidateEditRequest

func ValidateEditRequest(sl validator.StructLevel)

Types

type AggregationResult

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

type EditRequest struct {
	ID      string              `json:"-"`
	Title   string              `json:"title" binding:"required,max=255"`
	Type    string              `` /* 144-byte string literal not displayed */
	Columns []view.WidgetColumn `json:"columns" binding:"dive"`
	Content string              `json:"content"`
	Author  string              `json:"author" swaggerignore:"true"`
}

type ListRequest

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

type Response

type Response struct {
	ID      string              `bson:"_id" json:"_id"`
	Title   string              `bson:"title" json:"title"`
	Type    string              `bson:"type" json:"type"`
	Columns []view.WidgetColumn `bson:"columns" json:"columns,omitempty"`
	Content string              `bson:"content" json:"content,omitempty"`
	Author  *author.Author      `bson:"author" json:"author"`
	Created *datetime.CpsTime   `bson:"created" json:"created" swaggertype:"integer"`
	Updated *datetime.CpsTime   `bson:"updated" json:"updated" swaggertype:"integer"`
}

type Store

type Store interface {
	Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
	GetOneById(ctx context.Context, id string) (*Response, error)
	Insert(ctx context.Context, r EditRequest) (*Response, error)
	Update(ctx context.Context, r EditRequest) (*Response, error)
	Delete(ctx context.Context, id string) (bool, error)
}

func NewStore

func NewStore(dbClient mongo.DbClient, authorProvider author.Provider) Store

Jump to

Keyboard shortcuts

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