Documentation
¶
Overview ¶
Package documents implements a service for managing documents.
Index ¶
- Constants
- type DocumentView
- type Error
- type Service
- func (s *Service) CreateDocument(actor *domains.Actor, clan *domains.Clan, doc *domains.Document) (domains.ID, error)
- func (s *Service) DeleteDocument(actor *domains.Actor, documentId domains.ID) error
- func (s *Service) FindClanByGameAndNumber(gameID string, clanNo int) (*domains.Clan, error)
- func (s *Service) GetAllDocumentsForUserAcrossGames(actor *domains.Actor, docType domains.DocumentType, pageNumber, pageSize int) ([]*DocumentView, error)
- func (s *Service) GetDocument(actor *domains.Actor, documentId domains.ID) (*DocumentView, error)
- func (s *Service) GetDocumentContents(actor *domains.Actor, documentId domains.ID) (*domains.Document, error)
- func (s *Service) LoadDocxFromFS(actor *domains.Actor, clan *domains.Clan, path, name string, ...) (domains.ID, error)
- func (s *Service) LoadDocxFromRequest(r *http.Request) (domains.ID, error)
- func (s *Service) LoadMapFromFS(actor *domains.Actor, clan *domains.Clan, path, name string, ...) (domains.ID, error)
- func (s *Service) LoadMapFromRequest(r *http.Request) (domains.ID, error)
- func (s *Service) LoadReportFromFS(actor *domains.Actor, clan *domains.Clan, path, name string, ...) (domains.ID, error)
- func (s *Service) LoadReportFromRequest(r *http.Request) (domains.ID, error)
- func (s *Service) ShareDocumentById(actor, ally *domains.Actor, documentId domains.ID, canRead, canDelete bool) error
- func (s *Service) UpdateDocx(doc *domains.Document) error
- type UserDocumentView
Constants ¶
const (
ErrInvalidPath = Error("invalid path")
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DocumentView ¶
type DocumentView struct {
ID string `jsonapi:"primary,document"` // singular when sending a payload
OwnerHandle string `jsonapi:"attr,owner"` // handle of user that owns this document
UserHandle string `jsonapi:"attr,created-by"` // handle of user for this document
GameId string `jsonapi:"attr,game-id"` // game for this document
ClanNo string `jsonapi:"attr,clan"` // clan for this document
DocumentName string `jsonapi:"attr,document-name"` // untainted name of document
DocumentType string `jsonapi:"attr,document-type"` // for categorizing on the dashboards
CanRead bool `jsonapi:"attr,can-read"`
CanWrite bool `jsonapi:"attr,can-write"`
CanDelete bool `jsonapi:"attr,can-delete"`
CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"`
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
}
DocumentView is the JSON:API view for a document.
func (*DocumentView) JSONAPILinks ¶
func (d *DocumentView) JSONAPILinks() *jsonapi.Links
JSONAPILinks implements the jsonapi.Linkable interface for document-links
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides document management operations.
func (*Service) CreateDocument ¶
func (s *Service) CreateDocument(actor *domains.Actor, clan *domains.Clan, doc *domains.Document) (domains.ID, error)
CreateDocument creates a document.
Actor is the user/service requesting the creation. Owner is the user that will own the new document.
func (*Service) DeleteDocument ¶
DeleteDocument will return nil if the document doesn't exist. Returns an error if the actor is not authorized to delete it.
func (*Service) FindClanByGameAndNumber ¶
func (*Service) GetAllDocumentsForUserAcrossGames ¶
func (s *Service) GetAllDocumentsForUserAcrossGames(actor *domains.Actor, docType domains.DocumentType, pageNumber, pageSize int) ([]*DocumentView, error)
GetAllDocumentsForUserAcrossGames returns an unsorted list of documents that the actor has permissions to view. Returns an empty list (not a nil list) if there are no documents.
func (*Service) GetDocument ¶
GetDocument returns nil, nil if no data found
func (*Service) GetDocumentContents ¶
func (s *Service) GetDocumentContents(actor *domains.Actor, documentId domains.ID) (*domains.Document, error)
GetDocumentContents returns nil, nil if no data found
func (*Service) LoadDocxFromFS ¶
func (s *Service) LoadDocxFromFS(actor *domains.Actor, clan *domains.Clan, path, name string, canDelete, canRead, canShare, canWrite bool) (domains.ID, error)
LoadDocxFromFS loads the file, creates a Document, and returns the document ID.
func (*Service) LoadDocxFromRequest ¶
LoadDocxFromRequest loads a document from an http.Request.
func (*Service) LoadMapFromFS ¶
func (*Service) LoadMapFromRequest ¶
func (*Service) LoadReportFromFS ¶
func (s *Service) LoadReportFromFS(actor *domains.Actor, clan *domains.Clan, path, name string, canDelete, canRead, canShare, canWrite bool) (domains.ID, error)
LoadReportFromFS loads the file, creates a Document, and returns the document ID.
func (*Service) LoadReportFromRequest ¶
LoadReportFromRequest loads a document from an http.Request.
func (*Service) ShareDocumentById ¶
func (s *Service) ShareDocumentById(actor, ally *domains.Actor, documentId domains.ID, canRead, canDelete bool) error
ShareDocumentById shares a document.
Actor is the user requesting the share. The actor must own the document and have permission to read and share it.
Ally is the user that will own the shared document.
type UserDocumentView ¶
type UserDocumentView struct {
ID string `jsonapi:"primary,user-document"` // singular when sending a payload
Owner string `jsonapi:"attr,owner"` // handle of user that owns this document
Game string `jsonapi:"attr,game"`
Clan string `jsonapi:"attr,clan"` // four-digit clan number
DocumentName string `jsonapi:"attr,document-name"` // untainted name of document
DocumentType string `jsonapi:"attr,document-type"` // for categorizing on the dashboards
ProcessingStatus string `jsonapi:"attr,processing-status,omitempty"`
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
}
UserDocumentView is the JSON:API for a user document. This view of the document includes the game information.
func (*UserDocumentView) JSONAPILinks ¶
func (d *UserDocumentView) JSONAPILinks() *jsonapi.Links
JSONAPILinks implements the jsonapi.Linkable interface for user-document-links