webpublication

package
v0.0.0-...-99fd3eb Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusDraft      string = "draft"
	StatusEncrypting string = "encrypting"
	StatusError      string = "error"
	StatusOk         string = "ok"
)

Publication status

Variables

View Source
var ErrNotFound = errors.New("Publication not found")

ErrNotFound error trown when publication is not found

Functions

This section is empty.

Types

type Publication

type Publication struct {
	ID             int64  `json:"id"`
	UUID           string `json:"uuid"`
	Status         string `json:"status"`
	Title          string `json:"title,omitempty"`
	MasterFilename string `json:"masterFilename,omitempty"`
}

Publication struct defines a publication

type PublicationManager

type PublicationManager struct {
	// contains filtered or unexported fields
}

PublicationManager helper

func (PublicationManager) Add

func (pubManager PublicationManager) Add(pub Publication) error

Add adds a new publication Encrypts a master File and notifies the License server

func (PublicationManager) CheckByTitle

func (pubManager PublicationManager) CheckByTitle(title string) (int64, error)

CheckByTitle checks if the title of a publication exists or not in the db

func (PublicationManager) Delete

func (pubManager PublicationManager) Delete(id int64) error

Delete deletes a publication, selected by its numeric id

func (PublicationManager) Get

func (pubManager PublicationManager) Get(id int64) (Publication, error)

Get gets a publication by its ID

func (PublicationManager) GetByUUID

func (pubManager PublicationManager) GetByUUID(uuid string) (Publication, error)

GetByUUID returns a publication by its uuid

func (PublicationManager) List

func (pubManager PublicationManager) List(page int, pageNum int) func() (Publication, error)

List lists publications within a given range Parameters: page = number of items per page; pageNum = page offset (0 for the first page)

func (PublicationManager) Update

func (pubManager PublicationManager) Update(pub Publication) error

Update updates a publication Only the title is updated

func (PublicationManager) Upload

func (pubManager PublicationManager) Upload(file multipart.File, extension string, pub Publication) error

Upload creates a new publication, named after a POST form parameter. Encrypts a master File and notifies the License server

type WebPublication

type WebPublication interface {
	Get(id int64) (Publication, error)
	GetByUUID(uuid string) (Publication, error)
	Add(publication Publication) error
	Update(publication Publication) error
	Delete(id int64) error
	List(page int, pageNum int) func() (Publication, error)
	Upload(multipart.File, string, Publication) error
	CheckByTitle(title string) (int64, error)
}

WebPublication interface for publication db interaction

func Init

func Init(config config.Configuration, db *sql.DB) (i WebPublication, err error)

Init initializes the publication manager Creates the publication db table.

Jump to

Keyboard shortcuts

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