entitycategory

package
v0.0.0-...-8a398ea Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLinkedCategoryToEntity = errors.New("category is linked to entity")

Functions

func NewApi

func NewApi(
	store Store,
) common.CrudAPI

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 Category

type Category struct {
	ID      string            `bson:"_id" json:"_id"`
	Name    string            `bson:"name" json:"name"`
	Author  string            `bson:"author" json:"author"`
	Created *datetime.CpsTime `bson:"created" json:"created" swaggertype:"integer"`
	Updated *datetime.CpsTime `bson:"updated" json:"updated" swaggertype:"integer"`
}

type EditRequest

type EditRequest struct {
	ID     string `json:"-"`
	Name   string `json:"name" binding:"required,max=255"`
	Author string `json:"author" swaggerignore:"true"`
}

type ListRequest

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

type Response

type Response struct {
	ID      string            `bson:"_id" json:"_id"`
	Name    string            `bson:"name" json:"name"`
	Author  *author.Author    `bson:"author" json:"author"`
	Created *datetime.CpsTime `bson:"created" json:"created"`
	Updated *datetime.CpsTime `bson:"updated" json:"updated"`
}

type Store

type Store interface {
	Find(ctx context.Context, r ListRequest) (*AggregationResult, error)
	GetOneBy(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, userID 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