WIP more deletion checks
This commit is contained in:
1 parent
676976e7d3
commit
a5fe46e50e
6 files changed
+63
-22
No files matched your search
@@ -23,6 +23,8 @@ type Controller interface {
|
||||
|
||||
// CreateDocument creates new document in space
|
||||
CreateDocument(spaceId string) (id string, err error)
|
||||
// DeleteDocument deletes a document from space
|
||||
DeleteDocument(spaceId, documentId string) (err error)
|
||||
// AllDocumentIds gets all ids of documents in space
|
||||
AllDocumentIds(spaceId string) (ids []string, err error)
|
||||
// AddText adds text to space document
|
||||
@@ -97,6 +99,10 @@ func (c *controller) CreateDocument(spaceId string) (id string, err error) {
|
||||
return c.docService.CreateDocument(spaceId)
|
||||
}
|
||||
|
||||
func (c *controller) DeleteDocument(spaceId, documentId string) (err error) {
|
||||
return c.docService.DeleteDocument(spaceId, documentId)
|
||||
}
|
||||
|
||||
func (c *controller) AllDocumentIds(spaceId string) (ids []string, err error) {
|
||||
return c.docService.AllDocumentIds(spaceId)
|
||||
}
|
||||
|
||||
@@ -53,10 +53,18 @@ func (s *service) CreateDocument(spaceId string) (id string, err error) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
id = doc.Tree().ID()
|
||||
id = doc.ID()
|
||||
return
|
||||
}
|
||||
|
||||
func (s *service) DeleteDocument(spaceId, documentId string) (err error) {
|
||||
space, err := s.spaceService.GetSpace(context.Background(), spaceId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return space.DeleteTree(context.Background(), documentId)
|
||||
}
|
||||
|
||||
func (s *service) AllDocumentIds(spaceId string) (ids []string, err error) {
|
||||
space, err := s.spaceService.GetSpace(context.Background(), spaceId)
|
||||
if err != nil {
|
||||
@@ -79,5 +87,5 @@ func (s *service) DumpDocumentTree(spaceId, documentId string) (dump string, err
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return doc.Tree().DebugDump()
|
||||
return doc.DebugDump()
|
||||
}
|
||||
Reference in new issue
Block a user