mirror of
https://github.com/documize/community.git
synced 2025-07-22 14:49:42 +02:00
refactored unique ID generator package
This commit is contained in:
parent
cf58f8164d
commit
fe05cf7bb5
16 changed files with 69 additions and 64 deletions
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/documize/community/core/secrets"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/core/stringutil"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/gorilla/mux"
|
||||
uuid "github.com/nu7hatch/gouuid"
|
||||
)
|
||||
|
@ -88,7 +89,7 @@ func SaveAsTemplate(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
docID := util.UniqueID()
|
||||
docID := uniqueid.Generate()
|
||||
doc.Template = true
|
||||
doc.Title = model.Name
|
||||
doc.Excerpt = model.Excerpt
|
||||
|
@ -116,7 +117,7 @@ func SaveAsTemplate(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
pageID := util.UniqueID()
|
||||
pageID := uniqueid.Generate()
|
||||
page.RefID = pageID
|
||||
|
||||
meta.PageID = pageID
|
||||
|
@ -134,7 +135,7 @@ func SaveAsTemplate(w http.ResponseWriter, r *http.Request) {
|
|||
attachments, _ := p.GetAttachments(model.DocumentID)
|
||||
for i, a := range attachments {
|
||||
a.DocumentID = docID
|
||||
a.RefID = util.UniqueID()
|
||||
a.RefID = uniqueid.Generate()
|
||||
a.ID = 0
|
||||
attachments[i] = a
|
||||
}
|
||||
|
@ -347,7 +348,7 @@ func StartDocumentFromSavedTemplate(w http.ResponseWriter, r *http.Request) {
|
|||
d.Slug = stringutil.MakeSlug(d.Title)
|
||||
d.Tags = ""
|
||||
d.LabelID = folderID
|
||||
documentID := util.UniqueID()
|
||||
documentID := uniqueid.Generate()
|
||||
d.RefID = documentID
|
||||
|
||||
var pages = []entity.Page{}
|
||||
|
@ -382,7 +383,7 @@ func StartDocumentFromSavedTemplate(w http.ResponseWriter, r *http.Request) {
|
|||
p.Context.Transaction = tx
|
||||
|
||||
// Prepare new document
|
||||
documentID = util.UniqueID()
|
||||
documentID = uniqueid.Generate()
|
||||
d.RefID = documentID
|
||||
d.Template = false
|
||||
d.LabelID = folderID
|
||||
|
@ -405,7 +406,7 @@ func StartDocumentFromSavedTemplate(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
page.DocumentID = documentID
|
||||
pageID := util.UniqueID()
|
||||
pageID := uniqueid.Generate()
|
||||
page.RefID = pageID
|
||||
|
||||
// meta := entity.PageMeta{}
|
||||
|
@ -440,7 +441,7 @@ func StartDocumentFromSavedTemplate(w http.ResponseWriter, r *http.Request) {
|
|||
a.Job = newUUID.String()
|
||||
random := secrets.GenerateSalt()
|
||||
a.FileID = random[0:9]
|
||||
attachmentID := util.UniqueID()
|
||||
attachmentID := uniqueid.Generate()
|
||||
a.RefID = attachmentID
|
||||
|
||||
err = p.AddAttachment(a)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue