item

package
v0.0.0-...-f1b04be Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2017 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package item provides a hight level API to handle items in a content tree.

The location of an item in the content tree is stored using the node package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Folder

type Folder struct {
	ID       string
	Name     string
	Parent   string
	Children []interface{}
	Path     []Path
}

Folder represents a folder in the content tree.

func NewFolder

func NewFolder(name string, parent string) Folder

NewFolder allocates a folder and returns a pointer to it.

func (Folder) PathID

func (f Folder) PathID() string

PathID returns the id of the item in the path to the node.

func (Folder) PathName

func (f Folder) PathName() string

PathName returns the name of the item in the path to the node.

type Path

type Path interface {
	PathID() string
	PathName() string
}

Path is an item in the path to the node.

type Report

type Report struct {
	ID      string
	Name    string
	Parent  string
	Content string
	Path    []Path
}

Report represents a report in the content tree.

func NewReport

func NewReport(name, parent, content string) Report

NewReport allocates a report and returns a pointer to it.

func (Report) PathID

func (r Report) PathID() string

PathID returns the id of the item in the path to the node.

func (Report) PathName

func (r Report) PathName() string

PathName returns the name of the item in the path to the node.

type Repository

type Repository interface {
	Get(ctx context.Context, id string) (i interface{}, err error)
	Put(ctx context.Context, i interface{}) (id string, err error)
}

Repository provides a limited interface to a storage layer.

type Service

type Service interface {
	Get(ctx context.Context, id string) (interface{}, error)
	AddFolder(ctx context.Context, name, parent string) (string, error)
	AddReport(ctx context.Context, name, parent, content string) (string, error)
}

Service is the interface that provides the basic Item methods.

func NewService

func NewService(repo Repository) Service

NewService returns a new instance of the default item Service.

Jump to

Keyboard shortcuts

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