mirror of
https://github.com/documize/community.git
synced 2025-07-21 14:19:43 +02:00
removed named sql statements
This commit is contained in:
parent
9ccd0fd19c
commit
8f80673cde
32 changed files with 218 additions and 937 deletions
|
@ -17,7 +17,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/account"
|
||||
|
@ -34,19 +33,11 @@ func (s Scope) Add(ctx domain.RequestContext, account account.Account) (err erro
|
|||
account.Created = time.Now().UTC()
|
||||
account.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO account (refid, orgid, userid, admin, editor, users, active, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to prepare insert for account")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(account.RefID, account.OrgID, account.UserID, account.Admin, account.Editor, account.Users, account.Active, account.Created, account.Revised)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO account (refid, orgid, userid, admin, editor, users, active, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
account.RefID, account.OrgID, account.UserID, account.Admin, account.Editor, account.Users, account.Active, account.Created, account.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to execute insert for account")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -106,7 +97,6 @@ func (s Scope) CountOrgAccounts(ctx domain.RequestContext) (c int) {
|
|||
if err == sql.ErrNoRows {
|
||||
return 0
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "count org accounts")
|
||||
return 0
|
||||
|
@ -119,18 +109,10 @@ func (s Scope) CountOrgAccounts(ctx domain.RequestContext) (c int) {
|
|||
func (s Scope) UpdateAccount(ctx domain.RequestContext, account account.Account) (err error) {
|
||||
account.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.PrepareNamed("UPDATE account SET userid=:userid, admin=:admin, editor=:editor, users=:users, active=:active, revised=:revised WHERE orgid=:orgid AND refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE account SET userid=:userid, admin=:admin, editor=:editor, users=:users, active=:active, revised=:revised WHERE orgid=:orgid AND refid=:refid", &account)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare update for account %s", account.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&account)
|
||||
if err != sql.ErrNoRows && err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute update for account %s", account.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/model/activity"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -33,19 +32,11 @@ func (s Scope) RecordUserActivity(ctx domain.RequestContext, activity activity.U
|
|||
activity.UserID = ctx.UserID
|
||||
activity.Created = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created) VALUES (?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare record user activity")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(activity.OrgID, activity.UserID, activity.LabelID, activity.SourceID, activity.SourceType, activity.ActivityType, activity.Created)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
activity.OrgID, activity.UserID, activity.LabelID, activity.SourceID, activity.SourceType, activity.ActivityType, activity.Created)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute record user activity")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/model/attachment"
|
||||
)
|
||||
|
||||
|
@ -37,18 +36,11 @@ func (s Scope) Add(ctx domain.RequestContext, a attachment.Attachment) (err erro
|
|||
bits := strings.Split(a.Filename, ".")
|
||||
a.Extension = bits[len(bits)-1]
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO attachment (refid, orgid, documentid, job, fileid, filename, data, extension, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO attachment (refid, orgid, documentid, job, fileid, filename, data, extension, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
a.RefID, a.OrgID, a.DocumentID, a.Job, a.FileID, a.Filename, a.Data, a.Extension, a.Created, a.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare insert attachment")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(a.RefID, a.OrgID, a.DocumentID, a.Job, a.FileID, a.Filename, a.Data, a.Extension, a.Created, a.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute insert attachment")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -56,18 +48,11 @@ func (s Scope) Add(ctx domain.RequestContext, a attachment.Attachment) (err erro
|
|||
|
||||
// GetAttachment returns the database attachment record specified by the parameters.
|
||||
func (s Scope) GetAttachment(ctx domain.RequestContext, orgID, attachmentID string) (a attachment.Attachment, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, orgid, documentid, job, fileid, filename, data, extension, created, revised FROM attachment WHERE orgid=? and refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&a, "SELECT id, refid, orgid, documentid, job, fileid, filename, data, extension, created, revised FROM attachment WHERE orgid=? and refid=?",
|
||||
orgID, attachmentID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare select attachment")
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&a, orgID, attachmentID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute select attachment")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -79,7 +64,6 @@ func (s Scope) GetAttachments(ctx domain.RequestContext, docID string) (a []atta
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute select attachments")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -91,7 +75,6 @@ func (s Scope) GetAttachmentsWithData(ctx domain.RequestContext, docID string) (
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute select attachments with data")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -40,21 +40,15 @@ func (s Scope) Record(ctx domain.RequestContext, t audit.EventType) {
|
|||
return
|
||||
}
|
||||
|
||||
stmt, err := tx.Preparex("INSERT INTO userevent (orgid, userid, eventtype, ip, created) VALUES (?, ?, ?, ?, ?)")
|
||||
_, err = tx.Exec("INSERT INTO userevent (orgid, userid, eventtype, ip, created) VALUES (?, ?, ?, ?, ?)",
|
||||
e.OrgID, e.UserID, e.Type, e.IP, e.Created)
|
||||
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
s.Runtime.Log.Error("prepare audit insert", err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(e.OrgID, e.UserID, e.Type, e.IP, e.Created)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
s.Runtime.Log.Error("execute audit insert", err)
|
||||
return
|
||||
}
|
||||
|
||||
stmt.Close()
|
||||
tx.Commit()
|
||||
|
||||
return
|
||||
|
|
|
@ -16,11 +16,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/block"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -36,18 +34,11 @@ func (s Scope) Add(ctx domain.RequestContext, b block.Block) (err error) {
|
|||
b.Created = time.Now().UTC()
|
||||
b.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO block (refid, orgid, labelid, userid, contenttype, pagetype, title, body, excerpt, rawbody, config, externalsource, used, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO block (refid, orgid, labelid, userid, contenttype, pagetype, title, body, excerpt, rawbody, config, externalsource, used, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
b.RefID, b.OrgID, b.LabelID, b.UserID, b.ContentType, b.PageType, b.Title, b.Body, b.Excerpt, b.RawBody, b.Config, b.ExternalSource, b.Used, b.Created, b.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare insert block")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(b.RefID, b.OrgID, b.LabelID, b.UserID, b.ContentType, b.PageType, b.Title, b.Body, b.Excerpt, b.RawBody, b.Config, b.ExternalSource, b.Used, b.Created, b.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute insert block")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -55,18 +46,11 @@ func (s Scope) Add(ctx domain.RequestContext, b block.Block) (err error) {
|
|||
|
||||
// Get returns requested reusable content block.
|
||||
func (s Scope) Get(ctx domain.RequestContext, id string) (b block.Block, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT a.id, a.refid, a.orgid, a.labelid, a.userid, a.contenttype, a.pagetype, a.title, a.body, a.excerpt, a.rawbody, a.config, a.externalsource, a.used, a.created, a.revised, b.firstname, b.lastname FROM block a LEFT JOIN user b ON a.userid = b.refid WHERE a.orgid=? AND a.refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&b, "SELECT a.id, a.refid, a.orgid, a.labelid, a.userid, a.contenttype, a.pagetype, a.title, a.body, a.excerpt, a.rawbody, a.config, a.externalsource, a.used, a.created, a.revised, b.firstname, b.lastname FROM block a LEFT JOIN user b ON a.userid = b.refid WHERE a.orgid=? AND a.refid=?",
|
||||
ctx.OrgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare select block")
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&b, ctx.OrgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute select block")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -78,7 +62,6 @@ func (s Scope) GetBySpace(ctx domain.RequestContext, spaceID string) (b []block.
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "select space blocks")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -86,18 +69,10 @@ func (s Scope) GetBySpace(ctx domain.RequestContext, spaceID string) (b []block.
|
|||
|
||||
// IncrementUsage increments usage counter for content block.
|
||||
func (s Scope) IncrementUsage(ctx domain.RequestContext, id string) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE block SET used=used+1, revised=? WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE block SET used=used+1, revised=? WHERE orgid=? AND refid=?", time.Now().UTC(), ctx.OrgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare increment block usage")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(time.Now().UTC(), ctx.OrgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute increment block usage")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -105,18 +80,10 @@ func (s Scope) IncrementUsage(ctx domain.RequestContext, id string) (err error)
|
|||
|
||||
// DecrementUsage decrements usage counter for content block.
|
||||
func (s Scope) DecrementUsage(ctx domain.RequestContext, id string) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE block SET used=used-1, revised=? WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE block SET used=used-1, revised=? WHERE orgid=? AND refid=?", time.Now().UTC(), ctx.OrgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare decrement block usage")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(time.Now().UTC(), ctx.OrgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute decrement block usage")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -124,23 +91,13 @@ func (s Scope) DecrementUsage(ctx domain.RequestContext, id string) (err error)
|
|||
|
||||
// RemoveReference clears page.blockid for given blockID.
|
||||
func (s Scope) RemoveReference(ctx domain.RequestContext, id string) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE page SET blockid='', revised=? WHERE orgid=? AND blockid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare remove block ref")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(time.Now().UTC(), ctx.OrgID, id)
|
||||
_, err = ctx.Transaction.Exec("UPDATE page SET blockid='', revised=? WHERE orgid=? AND blockid=?", time.Now().UTC(), ctx.OrgID, id)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute remove block ref")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -150,19 +107,10 @@ func (s Scope) RemoveReference(ctx domain.RequestContext, id string) (err error)
|
|||
func (s Scope) Update(ctx domain.RequestContext, b block.Block) (err error) {
|
||||
b.Revised = time.Now().UTC()
|
||||
|
||||
var stmt *sqlx.NamedStmt
|
||||
stmt, err = ctx.Transaction.PrepareNamed("UPDATE block SET title=:title, body=:body, excerpt=:excerpt, rawbody=:rawbody, config=:config, revised=:revised WHERE orgid=:orgid AND refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE block SET title=:title, body=:body, excerpt=:excerpt, rawbody=:rawbody, config=:config, revised=:revised WHERE orgid=:orgid AND refid=:refid", b)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare update block")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&b)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute update block")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -19,7 +19,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/category"
|
||||
|
@ -36,18 +35,11 @@ func (s Scope) Add(ctx domain.RequestContext, c category.Category) (err error) {
|
|||
c.Created = time.Now().UTC()
|
||||
c.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO category (refid, orgid, labelid, category, created, revised) VALUES (?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO category (refid, orgid, labelid, category, created, revised) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
c.RefID, c.OrgID, c.LabelID, c.Category, c.Created, c.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to prepare insert category")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(c.RefID, c.OrgID, c.LabelID, c.Category, c.Created, c.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to execute insert category")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -70,7 +62,6 @@ func (s Scope) GetBySpace(ctx domain.RequestContext, spaceID string) (c []catego
|
|||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select categories for space %s", spaceID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -93,7 +84,6 @@ func (s Scope) GetAllBySpace(ctx domain.RequestContext, spaceID string) (c []cat
|
|||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select all categories for space %s", spaceID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -103,18 +93,10 @@ func (s Scope) GetAllBySpace(ctx domain.RequestContext, spaceID string) (c []cat
|
|||
func (s Scope) Update(ctx domain.RequestContext, c category.Category) (err error) {
|
||||
c.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.PrepareNamed("UPDATE category SET category=:category, revised=:revised WHERE orgid=:orgid AND refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE category SET category=:category, revised=:revised WHERE orgid=:orgid AND refid=:refid", c)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare update for category %s", c.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&c)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute update for category %s", c.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -122,19 +104,11 @@ func (s Scope) Update(ctx domain.RequestContext, c category.Category) (err error
|
|||
|
||||
// Get returns specified category
|
||||
func (s Scope) Get(ctx domain.RequestContext, id string) (c category.Category, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, orgid, labelid, category, created, revised FROM category WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare select for category %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&c, ctx.OrgID, id)
|
||||
err = s.Runtime.Db.Get(&c, "SELECT id, refid, orgid, labelid, category, created, revised FROM category WHERE orgid=? AND refid=?",
|
||||
ctx.OrgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to get category %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -151,18 +125,11 @@ func (s Scope) AssociateDocument(ctx domain.RequestContext, m category.Member) (
|
|||
m.Created = time.Now().UTC()
|
||||
m.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO categorymember (refid, orgid, categoryid, labelid, documentid, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO categorymember (refid, orgid, categoryid, labelid, documentid, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
m.RefID, m.OrgID, m.CategoryID, m.LabelID, m.DocumentID, m.Created, m.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to prepare insert categorymember")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(m.RefID, m.OrgID, m.CategoryID, m.LabelID, m.DocumentID, m.Created, m.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to execute insert categorymember")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -219,7 +186,6 @@ func (s Scope) GetSpaceCategorySummary(ctx domain.RequestContext, spaceID string
|
|||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select category summary for space %s", spaceID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -236,7 +202,6 @@ func (s Scope) GetDocumentCategoryMembership(ctx domain.RequestContext, document
|
|||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select categories for document %s", documentID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/doc"
|
||||
|
@ -35,19 +34,11 @@ func (s Scope) Add(ctx domain.RequestContext, document doc.Document) (err error)
|
|||
document.Created = time.Now().UTC()
|
||||
document.Revised = document.Created // put same time in both fields
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO document (refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare insert document")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(document.RefID, document.OrgID, document.LabelID, document.UserID, document.Job, document.Location, document.Title, document.Excerpt, document.Slug, document.Tags, document.Template, document.Created, document.Revised)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO document (refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
document.RefID, document.OrgID, document.LabelID, document.UserID, document.Job, document.Location, document.Title, document.Excerpt, document.Slug, document.Tags, document.Template, document.Created, document.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execuet insert document")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -55,18 +46,11 @@ func (s Scope) Add(ctx domain.RequestContext, document doc.Document) (err error)
|
|||
|
||||
// Get fetches the document record with the given id fromt the document table and audits that it has been got.
|
||||
func (s Scope) Get(ctx domain.RequestContext, id string) (document doc.Document, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, layout, created, revised FROM document WHERE orgid=? and refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&document, "SELECT id, refid, orgid, labelid, userid, job, location, title, excerpt, slug, tags, template, layout, created, revised FROM document WHERE orgid=? and refid=?",
|
||||
ctx.OrgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare select document")
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&document, ctx.OrgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute select document")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -112,7 +96,6 @@ func (s Scope) GetAll() (ctx domain.RequestContext, documents []doc.Document, er
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "select documents")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -124,7 +107,6 @@ func (s Scope) GetBySpace(ctx domain.RequestContext, folderID string) (documents
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "select documents by space")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -150,7 +132,6 @@ func (s Scope) GetByTag(ctx domain.RequestContext, tag string) (documents []doc.
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "select documents by tag")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -173,7 +154,6 @@ func (s Scope) Templates(ctx domain.RequestContext) (documents []doc.Document, e
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "select document templates")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -201,7 +181,6 @@ func (s Scope) TemplatesBySpace(ctx domain.RequestContext, spaceID string) (docu
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "select space document templates")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -218,7 +197,6 @@ func (s Scope) PublicDocuments(ctx domain.RequestContext, orgID string) (documen
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute GetPublicDocuments for org %s%s", orgID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -246,7 +224,6 @@ func (s Scope) DocumentList(ctx domain.RequestContext) (documents []doc.Document
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "select documents list")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -256,19 +233,11 @@ func (s Scope) DocumentList(ctx domain.RequestContext) (documents []doc.Document
|
|||
func (s Scope) Update(ctx domain.RequestContext, document doc.Document) (err error) {
|
||||
document.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.PrepareNamed("UPDATE document SET labelid=:labelid, userid=:userid, job=:job, location=:location, title=:title, excerpt=:excerpt, slug=:slug, tags=:tags, template=:template, layout=:layout, revised=:revised WHERE orgid=:orgid AND refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare update document")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&document)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE document SET labelid=:labelid, userid=:userid, job=:job, location=:location, title=:title, excerpt=:excerpt, slug=:slug, tags=:tags, template=:template, layout=:layout, revised=:revised WHERE orgid=:orgid AND refid=:refid",
|
||||
&document)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute update document")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -278,19 +247,11 @@ func (s Scope) Update(ctx domain.RequestContext, document doc.Document) (err err
|
|||
func (s Scope) ChangeDocumentSpace(ctx domain.RequestContext, document, space string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE document SET labelid=?, revised=? WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare change document space %s", document))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(space, revised, ctx.OrgID, document)
|
||||
_, err = ctx.Transaction.Exec("UPDATE document SET labelid=?, revised=? WHERE orgid=? AND refid=?",
|
||||
space, revised, ctx.OrgID, document)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute change document space %s", document))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -298,18 +259,11 @@ func (s Scope) ChangeDocumentSpace(ctx domain.RequestContext, document, space st
|
|||
|
||||
// MoveDocumentSpace changes the space for client's organization's documents which have space "id", to "move".
|
||||
func (s Scope) MoveDocumentSpace(ctx domain.RequestContext, id, move string) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE document SET labelid=? WHERE orgid=? AND labelid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE document SET labelid=? WHERE orgid=? AND labelid=?",
|
||||
move, ctx.OrgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare document space move %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(move, ctx.OrgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute document space move %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -338,7 +292,7 @@ func (s Scope) Delete(ctx domain.RequestContext, documentID string) (rows int64,
|
|||
return b.DeleteConstrained(ctx.Transaction, "document", ctx.OrgID, documentID)
|
||||
}
|
||||
|
||||
// Delete removes all documents for given space.
|
||||
// DeleteBySpace removes all documents for given space.
|
||||
// Remove document pages, revisions, attachments, updates the search subsystem.
|
||||
func (s Scope) DeleteBySpace(ctx domain.RequestContext, spaceID string) (rows int64, err error) {
|
||||
b := mysql.BaseQuery{}
|
||||
|
|
|
@ -12,12 +12,12 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/core/uniqueid"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
|
@ -36,18 +36,11 @@ func (s Scope) Add(ctx domain.RequestContext, l link.Link) (err error) {
|
|||
l.Created = time.Now().UTC()
|
||||
l.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO link (refid, orgid, folderid, userid, sourcedocumentid, sourcepageid, targetdocumentid, targetid, linktype, orphan, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO link (refid, orgid, folderid, userid, sourcedocumentid, sourcepageid, targetdocumentid, targetid, linktype, orphan, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
l.RefID, l.OrgID, l.FolderID, l.UserID, l.SourceDocumentID, l.SourcePageID, l.TargetDocumentID, l.TargetID, l.LinkType, l.Orphan, l.Created, l.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare link insert")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(l.RefID, l.OrgID, l.FolderID, l.UserID, l.SourceDocumentID, l.SourcePageID, l.TargetDocumentID, l.TargetID, l.LinkType, l.Orphan, l.Created, l.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute link insert")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -62,7 +55,8 @@ func (s Scope) GetDocumentOutboundLinks(ctx domain.RequestContext, documentID st
|
|||
ctx.OrgID,
|
||||
documentID)
|
||||
|
||||
if err != nil {
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "select document oubound links")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -83,7 +77,8 @@ func (s Scope) GetPageLinks(ctx domain.RequestContext, documentID, pageID string
|
|||
documentID,
|
||||
pageID)
|
||||
|
||||
if err != nil {
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "get page links")
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -98,15 +93,13 @@ func (s Scope) GetPageLinks(ctx domain.RequestContext, documentID, pageID string
|
|||
func (s Scope) MarkOrphanDocumentLink(ctx domain.RequestContext, documentID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE link SET orphan=1, revised=? WHERE linktype='document' AND orgid=? AND targetdocumentid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE link SET orphan=1, revised=? WHERE linktype='document' AND orgid=? AND targetdocumentid=?",
|
||||
revised, ctx.OrgID, documentID)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
err = errors.Wrap(err, "mark link as orphan")
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(revised, ctx.OrgID, documentID)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -114,15 +107,12 @@ func (s Scope) MarkOrphanDocumentLink(ctx domain.RequestContext, documentID stri
|
|||
func (s Scope) MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE link SET orphan=1, revised=? WHERE linktype='section' AND orgid=? AND targetid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE link SET orphan=1, revised=? WHERE linktype='section' AND orgid=? AND targetid=?", revised, ctx.OrgID, pageID)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
err = errors.Wrap(err, "mark orphan page link")
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(revised, ctx.OrgID, pageID)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -130,15 +120,13 @@ func (s Scope) MarkOrphanPageLink(ctx domain.RequestContext, pageID string) (err
|
|||
func (s Scope) MarkOrphanAttachmentLink(ctx domain.RequestContext, attachmentID string) (err error) {
|
||||
revised := time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE link SET orphan=1, revised=? WHERE linktype='file' AND orgid=? AND targetid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE link SET orphan=1, revised=? WHERE linktype='file' AND orgid=? AND targetid=?",
|
||||
revised, ctx.OrgID, attachmentID)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
err = errors.Wrap(err, "mark orphan attachment link")
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(revised, ctx.OrgID, attachmentID)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/org"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -32,25 +31,17 @@ type Scope struct {
|
|||
}
|
||||
|
||||
// AddOrganization inserts the passed organization record into the organization table.
|
||||
func (s Scope) AddOrganization(ctx domain.RequestContext, org org.Organization) error {
|
||||
func (s Scope) AddOrganization(ctx domain.RequestContext, org org.Organization) (err error) {
|
||||
org.Created = time.Now().UTC()
|
||||
org.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex(
|
||||
"INSERT INTO organization (refid, company, title, message, url, domain, email, allowanonymousaccess, serial, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to prepare insert for org")
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(org.RefID, org.Company, org.Title, org.Message, strings.ToLower(org.URL), strings.ToLower(org.Domain),
|
||||
_, err = ctx.Transaction.Exec(
|
||||
"INSERT INTO organization (refid, company, title, message, url, domain, email, allowanonymousaccess, serial, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
org.RefID, org.Company, org.Title, org.Message, strings.ToLower(org.URL), strings.ToLower(org.Domain),
|
||||
strings.ToLower(org.Email), org.AllowAnonymousAccess, org.Serial, org.Created, org.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to execute insert for org")
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -88,33 +79,18 @@ func (s Scope) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
return
|
||||
}
|
||||
|
||||
var stmt *sqlx.Stmt
|
||||
stmt, err = s.Runtime.Db.Preparex("SELECT id, refid, company, title, message, url, domain, service as conversionendpoint, email, serial, active, allowanonymousaccess, authprovider, coalesce(authconfig,JSON_UNQUOTE('{}')) as authconfig, created, revised FROM organization WHERE domain=? AND active=1")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&o, "SELECT id, refid, company, title, message, url, domain, service as conversionendpoint, email, serial, active, allowanonymousaccess, authprovider, coalesce(authconfig,JSON_UNQUOTE('{}')) as authconfig, created, revised FROM organization WHERE domain=? AND active=1",
|
||||
subdomain)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare select for subdomain %s", subdomain))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&o, subdomain)
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// we try to match on empty domain as last resort
|
||||
stmt, err = s.Runtime.Db.Preparex("SELECT id, refid, company, title, message, url, domain, service as conversionendpoint, email, serial, active, allowanonymousaccess, authprovider, coalesce(authconfig,JSON_UNQUOTE('{}')) as authconfig, created, revised FROM organization WHERE domain='' AND active=1")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&o, "SELECT id, refid, company, title, message, url, domain, service as conversionendpoint, email, serial, active, allowanonymousaccess, authprovider, coalesce(authconfig,JSON_UNQUOTE('{}')) as authconfig, created, revised FROM organization WHERE domain='' AND active=1")
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to prepare select for empty subdomain")
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&o)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "unable to execute select for empty subdomain")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -124,18 +100,11 @@ func (s Scope) GetOrganizationByDomain(subdomain string) (o org.Organization, er
|
|||
func (s Scope) UpdateOrganization(ctx domain.RequestContext, org org.Organization) (err error) {
|
||||
org.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.PrepareNamed("UPDATE organization SET title=:title, message=:message, service=:conversionendpoint, email=:email, allowanonymousaccess=:allowanonymousaccess, revised=:revised WHERE refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE organization SET title=:title, message=:message, service=:conversionendpoint, email=:email, allowanonymousaccess=:allowanonymousaccess, revised=:revised WHERE refid=:refid",
|
||||
&org)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare update for org %s", org.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&org)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute update for org %s", org.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -149,18 +118,10 @@ func (s Scope) DeleteOrganization(ctx domain.RequestContext, orgID string) (rows
|
|||
|
||||
// RemoveOrganization sets the orgID organization to be inactive, thus executing a "soft delete" operation.
|
||||
func (s Scope) RemoveOrganization(ctx domain.RequestContext, orgID string) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE organization SET active=0 WHERE refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE organization SET active=0 WHERE refid=?", orgID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare soft delete for org %s", orgID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(orgID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute soft delete for org %s", orgID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -170,18 +131,11 @@ func (s Scope) RemoveOrganization(ctx domain.RequestContext, orgID string) (err
|
|||
func (s Scope) UpdateAuthConfig(ctx domain.RequestContext, org org.Organization) (err error) {
|
||||
org.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.PrepareNamed("UPDATE organization SET allowanonymousaccess=:allowanonymousaccess, authprovider=:authprovider, authconfig=:authconfig, revised=:revised WHERE refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE organization SET allowanonymousaccess=:allowanonymousaccess, authprovider=:authprovider, authconfig=:authconfig, revised=:revised WHERE refid=:refid",
|
||||
&org)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare UpdateAuthConfig %s", org.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&org)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute UpdateAuthConfig %s", org.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -227,47 +227,6 @@ func (h *Handler) GetPages(w http.ResponseWriter, r *http.Request) {
|
|||
response.WriteJSON(w, pages)
|
||||
}
|
||||
|
||||
// GetPagesBatch gets specified pages for document.
|
||||
func (h *Handler) GetPagesBatch(w http.ResponseWriter, r *http.Request) {
|
||||
method := "page.batch"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
documentID := request.Param(r, "documentID")
|
||||
if len(documentID) == 0 {
|
||||
response.WriteMissingDataError(w, method, "documentID")
|
||||
return
|
||||
}
|
||||
|
||||
if !permission.CanViewDocument(ctx, *h.Store, documentID) {
|
||||
response.WriteForbiddenError(w)
|
||||
return
|
||||
}
|
||||
|
||||
defer streamutil.Close(r.Body)
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
response.WriteBadRequestError(w, method, err.Error())
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
requestedPages := string(body)
|
||||
|
||||
pages, err := h.Store.Page.GetPagesWhereIn(ctx, documentID, requestedPages)
|
||||
if err == sql.ErrNoRows {
|
||||
response.WriteNotFoundError(w, method, documentID)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
response.WriteJSON(w, pages)
|
||||
}
|
||||
|
||||
// Delete deletes a page.
|
||||
func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
method := "page.delete"
|
||||
|
|
|
@ -12,16 +12,14 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/page"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -56,33 +54,14 @@ func (s Scope) Add(ctx domain.RequestContext, model page.NewPage) (err error) {
|
|||
model.Page.Sequence = maxSeq * 2
|
||||
}
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO page (refid, orgid, documentid, userid, contenttype, pagetype, level, title, body, revisions, sequence, blockid, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO page (refid, orgid, documentid, userid, contenttype, pagetype, level, title, body, revisions, sequence, blockid, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
model.Page.RefID, model.Page.OrgID, model.Page.DocumentID, model.Page.UserID, model.Page.ContentType, model.Page.PageType, model.Page.Level, model.Page.Title, model.Page.Body, model.Page.Revisions, model.Page.Sequence, model.Page.BlockID, model.Page.Created, model.Page.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare page insert")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(model.Page.RefID, model.Page.OrgID, model.Page.DocumentID, model.Page.UserID, model.Page.ContentType, model.Page.PageType, model.Page.Level, model.Page.Title, model.Page.Body, model.Page.Revisions, model.Page.Sequence, model.Page.BlockID, model.Page.Created, model.Page.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page insert")
|
||||
return
|
||||
}
|
||||
|
||||
stmt2, err := ctx.Transaction.Preparex("INSERT INTO pagemeta (pageid, orgid, userid, documentid, rawbody, config, externalsource, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt2)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare page meta insert")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt2.Exec(model.Meta.PageID, model.Meta.OrgID, model.Meta.UserID, model.Meta.DocumentID, model.Meta.RawBody, model.Meta.Config, model.Meta.ExternalSource, model.Meta.Created, model.Meta.Revised)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO pagemeta (pageid, orgid, userid, documentid, rawbody, config, externalsource, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
model.Meta.PageID, model.Meta.OrgID, model.Meta.UserID, model.Meta.DocumentID, model.Meta.RawBody, model.Meta.Config, model.Meta.ExternalSource, model.Meta.Created, model.Meta.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page meta insert")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -90,18 +69,11 @@ func (s Scope) Add(ctx domain.RequestContext, model page.NewPage) (err error) {
|
|||
|
||||
// Get returns the pageID page record from the page table.
|
||||
func (s Scope) Get(ctx domain.RequestContext, pageID string) (p page.Page, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT a.id, a.refid, a.orgid, a.documentid, a.userid, a.contenttype, a.pagetype, a.level, a.sequence, a.title, a.body, a.revisions, a.blockid, a.created, a.revised FROM page a WHERE a.orgid=? AND a.refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&p, "SELECT a.id, a.refid, a.orgid, a.documentid, a.userid, a.contenttype, a.pagetype, a.level, a.sequence, a.title, a.body, a.revisions, a.blockid, a.created, a.revised FROM page a WHERE a.orgid=? AND a.refid=?",
|
||||
ctx.OrgID, pageID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare get page")
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&p, ctx.OrgID, pageID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute get page")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -113,59 +85,6 @@ func (s Scope) GetPages(ctx domain.RequestContext, documentID string) (p []page.
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute get pages")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPagesWhereIn returns a slice, in presentation sequence, containing those page records for a given documentID
|
||||
// where their refid is in the comma-separated list passed as inPages.
|
||||
func (s Scope) GetPagesWhereIn(ctx domain.RequestContext, documentID, inPages string) (p []page.Page, err error) {
|
||||
args := []interface{}{ctx.OrgID, documentID}
|
||||
tempValues := strings.Split(inPages, ",")
|
||||
|
||||
sql := "SELECT a.id, a.refid, a.orgid, a.documentid, a.userid, a.contenttype, a.pagetype, a.level, a.sequence, a.title, a.body, a.blockid, a.revisions, a.created, a.revised FROM page a WHERE a.orgid=? AND a.documentid=? AND a.refid IN (?" + strings.Repeat(",?", len(tempValues)-1) + ") ORDER BY sequence"
|
||||
|
||||
inValues := make([]interface{}, len(tempValues))
|
||||
|
||||
for i, v := range tempValues {
|
||||
inValues[i] = interface{}(v)
|
||||
}
|
||||
|
||||
args = append(args, inValues...)
|
||||
|
||||
stmt, err := s.Runtime.Db.Preparex(sql)
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
rows, err := stmt.Queryx(args...)
|
||||
defer streamutil.Close(rows)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
page := page.Page{}
|
||||
|
||||
err = rows.StructScan(&page)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p = append(p, page)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -178,7 +97,6 @@ func (s Scope) GetPagesWithoutContent(ctx domain.RequestContext, documentID stri
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("Unable to execute select pages for org %s and document %s", ctx.OrgID, documentID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -191,17 +109,9 @@ func (s Scope) Update(ctx domain.RequestContext, page page.Page, refID, userID s
|
|||
|
||||
// Store revision history
|
||||
if !skipRevision {
|
||||
var stmt *sqlx.Stmt
|
||||
stmt, err = ctx.Transaction.Preparex("INSERT INTO revision (refid, orgid, documentid, ownerid, pageid, userid, contenttype, pagetype, title, body, rawbody, config, created, revised) SELECT ? as refid, a.orgid, a.documentid, a.userid as ownerid, a.refid as pageid, ? as userid, a.contenttype, a.pagetype, a.title, a.body, b.rawbody, b.config, ? as created, ? as revised FROM page a, pagemeta b WHERE a.refid=? AND a.refid=b.pageid")
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO revision (refid, orgid, documentid, ownerid, pageid, userid, contenttype, pagetype, title, body, rawbody, config, created, revised) SELECT ? as refid, a.orgid, a.documentid, a.userid as ownerid, a.refid as pageid, ? as userid, a.contenttype, a.pagetype, a.title, a.body, b.rawbody, b.config, ? as created, ? as revised FROM page a, pagemeta b WHERE a.refid=? AND a.refid=b.pageid",
|
||||
refID, userID, time.Now().UTC(), time.Now().UTC(), page.RefID)
|
||||
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare page revision insert")
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(refID, userID, time.Now().UTC(), time.Now().UTC(), page.RefID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page revision insert")
|
||||
return err
|
||||
|
@ -209,16 +119,9 @@ func (s Scope) Update(ctx domain.RequestContext, page page.Page, refID, userID s
|
|||
}
|
||||
|
||||
// Update page
|
||||
var stmt2 *sqlx.NamedStmt
|
||||
stmt2, err = ctx.Transaction.PrepareNamed("UPDATE page SET documentid=:documentid, level=:level, title=:title, body=:body, revisions=:revisions, sequence=:sequence, revised=:revised WHERE orgid=:orgid AND refid=:refid")
|
||||
defer streamutil.Close(stmt2)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE page SET documentid=:documentid, level=:level, title=:title, body=:body, revisions=:revisions, sequence=:sequence, revised=:revised WHERE orgid=:orgid AND refid=:refid",
|
||||
&page)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare page insert")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt2.Exec(&page)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page insert")
|
||||
return
|
||||
|
@ -226,18 +129,10 @@ func (s Scope) Update(ctx domain.RequestContext, page page.Page, refID, userID s
|
|||
|
||||
// Update revisions counter
|
||||
if !skipRevision {
|
||||
stmt3, err := ctx.Transaction.Preparex("UPDATE page SET revisions=revisions+1 WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt3)
|
||||
_, err = ctx.Transaction.Exec("UPDATE page SET revisions=revisions+1 WHERE orgid=? AND refid=?", ctx.OrgID, page.RefID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare page revision counter")
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = stmt3.Exec(ctx.OrgID, page.RefID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page revision counter")
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,19 +147,11 @@ func (s Scope) UpdateMeta(ctx domain.RequestContext, meta page.Meta, updateUserI
|
|||
meta.UserID = ctx.UserID
|
||||
}
|
||||
|
||||
var stmt *sqlx.NamedStmt
|
||||
stmt, err = ctx.Transaction.PrepareNamed("UPDATE pagemeta SET userid=:userid, documentid=:documentid, rawbody=:rawbody, config=:config, externalsource=:externalsource, revised=:revised WHERE orgid=:orgid AND pageid=:pageid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE pagemeta SET userid=:userid, documentid=:documentid, rawbody=:rawbody, config=:config, externalsource=:externalsource, revised=:revised WHERE orgid=:orgid AND pageid=:pageid",
|
||||
&meta)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare page meta update")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&meta)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page meta update")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -273,18 +160,10 @@ func (s Scope) UpdateMeta(ctx domain.RequestContext, meta page.Meta, updateUserI
|
|||
// UpdateSequence changes the presentation sequence of the pageID page in the document.
|
||||
// It then propagates that change into the search table and audits that it has occurred.
|
||||
func (s Scope) UpdateSequence(ctx domain.RequestContext, documentID, pageID string, sequence float64) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE page SET sequence=? WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE page SET sequence=? WHERE orgid=? AND refid=?", sequence, ctx.OrgID, pageID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare page sequence update")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(sequence, ctx.OrgID, pageID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page sequence update")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -293,18 +172,10 @@ func (s Scope) UpdateSequence(ctx domain.RequestContext, documentID, pageID stri
|
|||
// UpdateLevel changes the heading level of the pageID page in the document.
|
||||
// It then propagates that change into the search table and audits that it has occurred.
|
||||
func (s Scope) UpdateLevel(ctx domain.RequestContext, documentID, pageID string, level int) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE page SET level=? WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE page SET level=? WHERE orgid=? AND refid=?", level, ctx.OrgID, pageID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare page level update")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(level, ctx.OrgID, pageID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page level update")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -325,18 +196,11 @@ func (s Scope) Delete(ctx domain.RequestContext, documentID, pageID string) (row
|
|||
|
||||
// GetPageMeta returns the meta information associated with the page.
|
||||
func (s Scope) GetPageMeta(ctx domain.RequestContext, pageID string) (meta page.Meta, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, pageid, orgid, userid, documentid, rawbody, coalesce(config,JSON_UNQUOTE('{}')) as config, externalsource, created, revised FROM pagemeta WHERE orgid=? AND pageid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&meta, "SELECT id, pageid, orgid, userid, documentid, rawbody, coalesce(config,JSON_UNQUOTE('{}')) as config, externalsource, created, revised FROM pagemeta WHERE orgid=? AND pageid=?",
|
||||
ctx.OrgID, pageID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare get page meta")
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&meta, ctx.OrgID, pageID)
|
||||
if err != nil {
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "execute get page meta")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -353,7 +217,6 @@ func (s Scope) GetDocumentPageMeta(ctx domain.RequestContext, documentID string,
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "get document page meta")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -365,18 +228,11 @@ func (s Scope) GetDocumentPageMeta(ctx domain.RequestContext, documentID string,
|
|||
|
||||
// GetPageRevision returns the revisionID page revision record.
|
||||
func (s Scope) GetPageRevision(ctx domain.RequestContext, revisionID string) (revision page.Revision, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, orgid, documentid, ownerid, pageid, userid, contenttype, pagetype, title, body, coalesce(rawbody, '') as rawbody, coalesce(config,JSON_UNQUOTE('{}')) as config, created, revised FROM revision WHERE orgid=? and refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&revision, "SELECT id, refid, orgid, documentid, ownerid, pageid, userid, contenttype, pagetype, title, body, coalesce(rawbody, '') as rawbody, coalesce(config,JSON_UNQUOTE('{}')) as config, created, revised FROM revision WHERE orgid=? and refid=?",
|
||||
ctx.OrgID, revisionID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare get page revisions")
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&revision, ctx.OrgID, revisionID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute get page revisions")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -389,7 +245,6 @@ func (s Scope) GetPageRevisions(ctx domain.RequestContext, pageID string) (revis
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "get page revisions")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -400,22 +255,21 @@ func (s Scope) GetPageRevisions(ctx domain.RequestContext, pageID string) (revis
|
|||
func (s Scope) GetDocumentRevisions(ctx domain.RequestContext, documentID string) (revisions []page.Revision, err error) {
|
||||
err = s.Runtime.Db.Select(&revisions, "SELECT a.id, a.refid, a.orgid, a.documentid, a.ownerid, a.pageid, a.userid, a.contenttype, a.pagetype, a.title, /*a.body, a.rawbody, a.config,*/ a.created, a.revised, coalesce(b.email,'') as email, coalesce(b.firstname,'') as firstname, coalesce(b.lastname,'') as lastname, coalesce(b.initials,'') as initials, coalesce(p.revisions, 0) as revisions FROM revision a LEFT JOIN user b ON a.userid=b.refid LEFT JOIN page p ON a.pageid=p.refid WHERE a.orgid=? AND a.documentid=? AND a.pagetype='section' ORDER BY a.id DESC", ctx.OrgID, documentID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "get document revisions")
|
||||
return
|
||||
}
|
||||
|
||||
if len(revisions) == 0 {
|
||||
revisions = []page.Revision{}
|
||||
}
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, "get document revisions")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePageRevisions deletes all of the page revision records for a given pageID.
|
||||
func (s Scope) DeletePageRevisions(ctx domain.RequestContext, pageID string) (rows int64, err error) {
|
||||
b := mysql.BaseQuery{}
|
||||
rows, err =b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM revision WHERE orgid='%s' AND pageid='%s'", ctx.OrgID, pageID))
|
||||
rows, err = b.DeleteWhere(ctx.Transaction, fmt.Sprintf("DELETE FROM revision WHERE orgid='%s' AND pageid='%s'", ctx.OrgID, pageID))
|
||||
|
||||
return
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/permission"
|
||||
|
@ -35,18 +34,11 @@ type Scope struct {
|
|||
func (s Scope) AddPermission(ctx domain.RequestContext, r permission.Permission) (err error) {
|
||||
r.Created = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO permission (orgid, who, whoid, action, scope, location, refid, created) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO permission (orgid, who, whoid, action, scope, location, refid, created) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
r.OrgID, r.Who, r.WhoID, string(r.Action), r.Scope, r.Location, r.RefID, r.Created)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to prepare insert permission")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(r.OrgID, r.Who, r.WhoID, string(r.Action), r.Scope, r.Location, r.RefID, r.Created)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to execute insert permission")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -79,7 +71,6 @@ func (s Scope) GetUserSpacePermissions(ctx domain.RequestContext, spaceID string
|
|||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select user permissions %s", ctx.UserID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -101,7 +92,6 @@ func (s Scope) GetSpacePermissions(ctx domain.RequestContext, spaceID string) (r
|
|||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select space permissions %s", ctx.UserID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -173,7 +163,6 @@ func (s Scope) GetCategoryPermissions(ctx domain.RequestContext, catID string) (
|
|||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select category permissions %s", catID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -198,7 +187,6 @@ func (s Scope) GetCategoryUsers(ctx domain.RequestContext, catID string) (u []us
|
|||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select users for category %s", catID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -16,11 +16,9 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/pin"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -43,18 +41,11 @@ func (s Scope) Add(ctx domain.RequestContext, pin pin.Pin) (err error) {
|
|||
pin.Revised = time.Now().UTC()
|
||||
pin.Sequence = maxSeq + 1
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO pin (refid, orgid, userid, labelid, documentid, pin, sequence, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO pin (refid, orgid, userid, labelid, documentid, pin, sequence, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
pin.RefID, pin.OrgID, pin.UserID, pin.FolderID, pin.DocumentID, pin.Pin, pin.Sequence, pin.Created, pin.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare pin insert")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(pin.RefID, pin.OrgID, pin.UserID, pin.FolderID, pin.DocumentID, pin.Pin, pin.Sequence, pin.Created, pin.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute pin insert")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -62,18 +53,11 @@ func (s Scope) Add(ctx domain.RequestContext, pin pin.Pin) (err error) {
|
|||
|
||||
// GetPin returns requested pinned item.
|
||||
func (s Scope) GetPin(ctx domain.RequestContext, id string) (pin pin.Pin, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, orgid, userid, labelid as folderid, documentid, pin, sequence, created, revised FROM pin WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&pin, "SELECT id, refid, orgid, userid, labelid as folderid, documentid, pin, sequence, created, revised FROM pin WHERE orgid=? AND refid=?",
|
||||
ctx.OrgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare select for pin %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&pin, ctx.OrgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute select for pin %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -85,7 +69,6 @@ func (s Scope) GetUserPins(ctx domain.RequestContext, userID string) (pins []pin
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute select pins for org %s and user %s", ctx.OrgID, userID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -95,19 +78,11 @@ func (s Scope) GetUserPins(ctx domain.RequestContext, userID string) (pins []pin
|
|||
func (s Scope) UpdatePin(ctx domain.RequestContext, pin pin.Pin) (err error) {
|
||||
pin.Revised = time.Now().UTC()
|
||||
|
||||
var stmt *sqlx.NamedStmt
|
||||
stmt, err = ctx.Transaction.PrepareNamed("UPDATE pin SET labelid=:folderid, documentid=:documentid, pin=:pin, sequence=:sequence, revised=:revised WHERE orgid=:orgid AND refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE pin SET labelid=:folderid, documentid=:documentid, pin=:pin, sequence=:sequence, revised=:revised WHERE orgid=:orgid AND refid=:refid",
|
||||
&pin)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare pin update %s", pin.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&pin)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute pin update %s", pin.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -115,18 +90,11 @@ func (s Scope) UpdatePin(ctx domain.RequestContext, pin pin.Pin) (err error) {
|
|||
|
||||
// UpdatePinSequence updates existing pinned item sequence number
|
||||
func (s Scope) UpdatePinSequence(ctx domain.RequestContext, pinID string, sequence int) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE pin SET sequence=?, revised=? WHERE orgid=? AND userid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE pin SET sequence=?, revised=? WHERE orgid=? AND userid=? AND refid=?",
|
||||
sequence, time.Now().UTC(), ctx.OrgID, ctx.UserID, pinID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare pin sequence update %s", pinID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(sequence, time.Now().UTC(), ctx.OrgID, ctx.UserID, pinID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute pin sequence update %s", pinID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -37,33 +37,18 @@ type Scope struct {
|
|||
// searchable items. Any existing document entries are removed.
|
||||
func (s Scope) IndexDocument(ctx domain.RequestContext, doc doc.Document, a []attachment.Attachment) (err error) {
|
||||
// remove previous search entries
|
||||
var stmt1 *sqlx.Stmt
|
||||
stmt1, err = ctx.Transaction.Preparex("DELETE FROM search WHERE orgid=? AND documentid=? AND (itemtype='doc' OR itemtype='file' OR itemtype='tag')")
|
||||
defer streamutil.Close(stmt1)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare delete document index entries")
|
||||
return
|
||||
}
|
||||
_, err = ctx.Transaction.Exec("DELETE FROM search WHERE orgid=? AND documentid=? AND (itemtype='doc' OR itemtype='file' OR itemtype='tag')",
|
||||
ctx.OrgID, doc.RefID)
|
||||
|
||||
_, err = stmt1.Exec(ctx.OrgID, doc.RefID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute delete document index entries")
|
||||
return
|
||||
}
|
||||
|
||||
// insert doc title
|
||||
var stmt2 *sqlx.Stmt
|
||||
stmt2, err = ctx.Transaction.Preparex("INSERT INTO search (orgid, documentid, itemid, itemtype, content) VALUES (?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt2)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare insert document title entry")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt2.Exec(ctx.OrgID, doc.RefID, "", "doc", doc.Title)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO search (orgid, documentid, itemid, itemtype, content) VALUES (?, ?, ?, ?, ?)",
|
||||
ctx.OrgID, doc.RefID, "", "doc", doc.Title)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute insert document title entry")
|
||||
return
|
||||
}
|
||||
|
||||
// insert doc tags
|
||||
|
@ -73,15 +58,9 @@ func (s Scope) IndexDocument(ctx domain.RequestContext, doc doc.Document, a []at
|
|||
continue
|
||||
}
|
||||
|
||||
var stmt3 *sqlx.Stmt
|
||||
stmt3, err = ctx.Transaction.Preparex("INSERT INTO search (orgid, documentid, itemid, itemtype, content) VALUES (?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt3)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare insert document tag entry")
|
||||
return
|
||||
}
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO search (orgid, documentid, itemid, itemtype, content) VALUES (?, ?, ?, ?, ?)",
|
||||
ctx.OrgID, doc.RefID, "", "tag", t)
|
||||
|
||||
_, err = stmt3.Exec(ctx.OrgID, doc.RefID, "", "tag", t)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute insert document tag entry")
|
||||
return
|
||||
|
@ -89,18 +68,11 @@ func (s Scope) IndexDocument(ctx domain.RequestContext, doc doc.Document, a []at
|
|||
}
|
||||
|
||||
for _, file := range a {
|
||||
var stmt4 *sqlx.Stmt
|
||||
stmt4, err = ctx.Transaction.Preparex("INSERT INTO search (orgid, documentid, itemid, itemtype, content) VALUES (?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt4)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare insert document file entry")
|
||||
return
|
||||
}
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO search (orgid, documentid, itemid, itemtype, content) VALUES (?, ?, ?, ?, ?)",
|
||||
ctx.OrgID, doc.RefID, file.RefID, "file", file.Filename)
|
||||
|
||||
_, err = stmt4.Exec(ctx.OrgID, doc.RefID, file.RefID, "file", file.Filename)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute insert document file entry")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,19 +81,10 @@ func (s Scope) IndexDocument(ctx domain.RequestContext, doc doc.Document, a []at
|
|||
|
||||
// DeleteDocument removes all search entries for document.
|
||||
func (s Scope) DeleteDocument(ctx domain.RequestContext, ID string) (err error) {
|
||||
// remove all search entries
|
||||
var stmt1 *sqlx.Stmt
|
||||
stmt1, err = ctx.Transaction.Preparex("DELETE FROM search WHERE orgid=? AND documentid=?")
|
||||
defer streamutil.Close(stmt1)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare delete document entries")
|
||||
return
|
||||
}
|
||||
_, err = ctx.Transaction.Exec("DELETE FROM search WHERE orgid=? AND documentid=?", ctx.OrgID, ID)
|
||||
|
||||
_, err = stmt1.Exec(ctx.OrgID, ID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute delete document entries")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -131,27 +94,11 @@ func (s Scope) DeleteDocument(ctx domain.RequestContext, ID string) (err error)
|
|||
// Any existing document entries are removed.
|
||||
func (s Scope) IndexContent(ctx domain.RequestContext, p page.Page) (err error) {
|
||||
// remove previous search entries
|
||||
var stmt1 *sqlx.Stmt
|
||||
stmt1, err = ctx.Transaction.Preparex("DELETE FROM search WHERE orgid=? AND documentid=? AND itemid=? AND itemtype='page'")
|
||||
defer streamutil.Close(stmt1)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare delete document content entry")
|
||||
return
|
||||
}
|
||||
_, err = ctx.Transaction.Exec("DELETE FROM search WHERE orgid=? AND documentid=? AND itemid=? AND itemtype='page'",
|
||||
ctx.OrgID, p.DocumentID, p.RefID)
|
||||
|
||||
_, err = stmt1.Exec(ctx.OrgID, p.DocumentID, p.RefID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute delete document content entry")
|
||||
return
|
||||
}
|
||||
|
||||
// insert doc title
|
||||
var stmt2 *sqlx.Stmt
|
||||
stmt2, err = ctx.Transaction.Preparex("INSERT INTO search (orgid, documentid, itemid, itemtype, content) VALUES (?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt2)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare insert document content entry")
|
||||
return
|
||||
}
|
||||
|
||||
// prepare content
|
||||
|
@ -162,10 +109,10 @@ func (s Scope) IndexContent(ctx domain.RequestContext, p page.Page) (err error)
|
|||
}
|
||||
content = strings.TrimSpace(content)
|
||||
|
||||
_, err = stmt2.Exec(ctx.OrgID, p.DocumentID, p.RefID, "page", content)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO search (orgid, documentid, itemid, itemtype, content) VALUES (?, ?, ?, ?, ?)",
|
||||
ctx.OrgID, p.DocumentID, p.RefID, "page", content)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute insert document content entry")
|
||||
return
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -295,7 +242,6 @@ func (s Scope) matchFullText(ctx domain.RequestContext, keywords, itemType strin
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "search document "+itemType)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -353,7 +299,6 @@ func (s Scope) matchLike(ctx domain.RequestContext, keywords, itemType string) (
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "search document "+itemType)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
"database/sql"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
@ -30,18 +29,13 @@ func (s Scope) Get(area, path string) (value string, err error) {
|
|||
if path != "" {
|
||||
path = "." + path
|
||||
}
|
||||
|
||||
sql := "SELECT JSON_EXTRACT(`config`,'$" + path + "') FROM `config` WHERE `key` = '" + area + "';"
|
||||
|
||||
stmt, err := s.Runtime.Db.Preparex(sql)
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var item = make([]uint8, 0)
|
||||
|
||||
err = stmt.Get(&item)
|
||||
err = s.Runtime.Db.Get(&item, sql)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -55,7 +49,7 @@ func (s Scope) Get(area, path string) (value string, err error) {
|
|||
}
|
||||
|
||||
// Set writes a configuration JSON element to the config table.
|
||||
func (s Scope) Set(area, json string) error {
|
||||
func (s Scope) Set(area, json string) (err error) {
|
||||
if area == "" {
|
||||
return errors.New("no area")
|
||||
}
|
||||
|
@ -64,15 +58,8 @@ func (s Scope) Set(area, json string) error {
|
|||
"VALUES ('" + area + "','" + json +
|
||||
"') ON DUPLICATE KEY UPDATE `config`='" + json + "';"
|
||||
|
||||
stmt, err := s.Runtime.Db.Preparex(sql)
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = s.Runtime.Db.Exec(sql)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "failed to save global config value")
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = stmt.Exec()
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -86,16 +73,10 @@ func (s Scope) GetUser(orgID, userID, area, path string) (value string, err erro
|
|||
qry := "SELECT JSON_EXTRACT(`config`,'$" + path + "') FROM `userconfig` WHERE `key` = '" + area +
|
||||
"' AND `orgid` = '" + orgID + "' AND `userid` = '" + userID + "';"
|
||||
|
||||
stmt, err := s.Runtime.Db.Preparex(qry)
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var item = make([]uint8, 0)
|
||||
|
||||
err = stmt.Get(&item)
|
||||
err = s.Runtime.Db.Get(&item, qry)
|
||||
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return "", err
|
||||
}
|
||||
|
@ -109,7 +90,7 @@ func (s Scope) GetUser(orgID, userID, area, path string) (value string, err erro
|
|||
}
|
||||
|
||||
// SetUser writes a configuration JSON element to the userconfig table for the current user.
|
||||
func (s Scope) SetUser(orgID, userID, area, json string) error {
|
||||
func (s Scope) SetUser(orgID, userID, area, json string) (err error) {
|
||||
if area == "" {
|
||||
return errors.New("no area")
|
||||
}
|
||||
|
@ -118,14 +99,7 @@ func (s Scope) SetUser(orgID, userID, area, json string) error {
|
|||
"VALUES ('" + orgID + "','" + userID + "','" + area + "','" + json +
|
||||
"') ON DUPLICATE KEY UPDATE `config`='" + json + "';"
|
||||
|
||||
stmt, err := s.Runtime.Db.Preparex(sql)
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = stmt.Exec()
|
||||
_, err = s.Runtime.Db.Exec(sql)
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/domain/store/mysql"
|
||||
"github.com/documize/community/model/space"
|
||||
|
@ -35,18 +34,11 @@ func (s Scope) Add(ctx domain.RequestContext, sp space.Space) (err error) {
|
|||
sp.Created = time.Now().UTC()
|
||||
sp.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO label (refid, label, orgid, userid, type, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO label (refid, label, orgid, userid, type, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
sp.RefID, sp.Name, sp.OrgID, sp.UserID, sp.Type, sp.Created, sp.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to prepare insert for label")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(sp.RefID, sp.Name, sp.OrgID, sp.UserID, sp.Type, sp.Created, sp.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "unable to execute insert for label")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -54,18 +46,11 @@ func (s Scope) Add(ctx domain.RequestContext, sp space.Space) (err error) {
|
|||
|
||||
// Get returns a space from the store.
|
||||
func (s Scope) Get(ctx domain.RequestContext, id string) (sp space.Space, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id,refid,label as name,orgid,userid,type,created,revised FROM label WHERE orgid=? and refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&sp, "SELECT id,refid,label as name,orgid,userid,type,created,revised FROM label WHERE orgid=? and refid=?",
|
||||
ctx.OrgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare select for label %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&sp, ctx.OrgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select for label %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -79,7 +64,6 @@ func (s Scope) PublicSpaces(ctx domain.RequestContext, orgID string) (sp []space
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("Unable to execute GetPublicFolders for org %s", orgID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -108,7 +92,6 @@ func (s Scope) GetAll(ctx domain.RequestContext) (sp []space.Space, err error) {
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("failed space.GetAll org %s", ctx.OrgID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -118,18 +101,10 @@ func (s Scope) GetAll(ctx domain.RequestContext) (sp []space.Space, err error) {
|
|||
func (s Scope) Update(ctx domain.RequestContext, sp space.Space) (err error) {
|
||||
sp.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.PrepareNamed("UPDATE label SET label=:name, type=:type, userid=:userid, revised=:revised WHERE orgid=:orgid AND refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec("UPDATE label SET label=:name, type=:type, userid=:userid, revised=:revised WHERE orgid=:orgid AND refid=:refid", &sp)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare update for label %s", sp.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&sp)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute update for label %s", sp.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -14,7 +14,6 @@ package mysql
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
@ -25,15 +24,8 @@ type BaseQuery struct {
|
|||
|
||||
// Delete record.
|
||||
func (m *BaseQuery) Delete(tx *sqlx.Tx, table string, id string) (rows int64, err error) {
|
||||
stmt, err := tx.Preparex("DELETE FROM " + table + " WHERE refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
result, err := tx.Exec("DELETE FROM "+table+" WHERE refid=?", id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare delete of row in table %s", table))
|
||||
return
|
||||
}
|
||||
|
||||
result, err := stmt.Exec(id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to delete row in table %s", table))
|
||||
return
|
||||
|
@ -46,15 +38,8 @@ func (m *BaseQuery) Delete(tx *sqlx.Tx, table string, id string) (rows int64, er
|
|||
|
||||
// DeleteConstrained record constrained to Organization using refid.
|
||||
func (m *BaseQuery) DeleteConstrained(tx *sqlx.Tx, table string, orgID, id string) (rows int64, err error) {
|
||||
stmt, err := tx.Preparex("DELETE FROM " + table + " WHERE orgid=? AND refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
result, err := tx.Exec("DELETE FROM "+table+" WHERE orgid=? AND refid=?", orgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare constrained delete of row in table %s", table))
|
||||
return
|
||||
}
|
||||
|
||||
result, err := stmt.Exec(orgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to delete row in table %s", table))
|
||||
return
|
||||
|
@ -67,15 +52,8 @@ func (m *BaseQuery) DeleteConstrained(tx *sqlx.Tx, table string, orgID, id strin
|
|||
|
||||
// DeleteConstrainedWithID record constrained to Organization using non refid.
|
||||
func (m *BaseQuery) DeleteConstrainedWithID(tx *sqlx.Tx, table string, orgID, id string) (rows int64, err error) {
|
||||
stmt, err := tx.Preparex("DELETE FROM " + table + " WHERE orgid=? AND id=?")
|
||||
defer streamutil.Close(stmt)
|
||||
result, err := tx.Exec("DELETE FROM "+table+" WHERE orgid=? AND id=?", orgID, id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare ConstrainedWithID delete of row in table %s", table))
|
||||
return
|
||||
}
|
||||
|
||||
result, err := stmt.Exec(orgID, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to delete row in table %s", table))
|
||||
return
|
||||
|
@ -89,6 +67,7 @@ func (m *BaseQuery) DeleteConstrainedWithID(tx *sqlx.Tx, table string, orgID, id
|
|||
// DeleteWhere free form query.
|
||||
func (m *BaseQuery) DeleteWhere(tx *sqlx.Tx, statement string) (rows int64, err error) {
|
||||
result, err := tx.Exec(statement)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to delete rows: %s", statement))
|
||||
return
|
||||
|
|
|
@ -242,7 +242,6 @@ type PageStorer interface {
|
|||
Add(ctx RequestContext, model page.NewPage) (err error)
|
||||
Get(ctx RequestContext, pageID string) (p page.Page, err error)
|
||||
GetPages(ctx RequestContext, documentID string) (p []page.Page, err error)
|
||||
GetPagesWhereIn(ctx RequestContext, documentID, inPages string) (p []page.Page, err error)
|
||||
GetPagesWithoutContent(ctx RequestContext, documentID string) (pages []page.Page, err error)
|
||||
Update(ctx RequestContext, page page.Page, refID, userID string, skipRevision bool) (err error)
|
||||
UpdateMeta(ctx RequestContext, meta page.Meta, updateUserID bool) (err error)
|
||||
|
|
|
@ -18,7 +18,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/streamutil"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/model/user"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -34,18 +33,11 @@ func (s Scope) Add(ctx domain.RequestContext, u user.User) (err error) {
|
|||
u.Created = time.Now().UTC()
|
||||
u.Revised = time.Now().UTC()
|
||||
|
||||
stmt, err := ctx.Transaction.Preparex("INSERT INTO user (refid, firstname, lastname, email, initials, password, salt, reset, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("INSERT INTO user (refid, firstname, lastname, email, initials, password, salt, reset, created, revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
u.RefID, u.Firstname, u.Lastname, strings.ToLower(u.Email), u.Initials, u.Password, u.Salt, "", u.Created, u.Revised)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare user insert")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(u.RefID, u.Firstname, u.Lastname, strings.ToLower(u.Email), u.Initials, u.Password, u.Salt, "", u.Created, u.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute user insert")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -53,18 +45,10 @@ func (s Scope) Add(ctx domain.RequestContext, u user.User) (err error) {
|
|||
|
||||
// Get returns the user record for the given id.
|
||||
func (s Scope) Get(ctx domain.RequestContext, id string) (u user.User, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, created, revised FROM user WHERE refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&u, "SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, created, revised FROM user WHERE refid=?", id)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to prepare select for user %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&u, id)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select for user %s", id))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -74,18 +58,11 @@ func (s Scope) Get(ctx domain.RequestContext, id string) (u user.User, err error
|
|||
func (s Scope) GetByDomain(ctx domain.RequestContext, domain, email string) (u user.User, err error) {
|
||||
email = strings.TrimSpace(strings.ToLower(email))
|
||||
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT u.id, u.refid, u.firstname, u.lastname, u.email, u.initials, u.global, u.password, u.salt, u.reset, u.created, u.revised FROM user u, account a, organization o WHERE TRIM(LOWER(u.email))=? AND u.refid=a.userid AND a.orgid=o.refid AND TRIM(LOWER(o.domain))=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&u, "SELECT u.id, u.refid, u.firstname, u.lastname, u.email, u.initials, u.global, u.password, u.salt, u.reset, u.created, u.revised FROM user u, account a, organization o WHERE TRIM(LOWER(u.email))=? AND u.refid=a.userid AND a.orgid=o.refid AND TRIM(LOWER(o.domain))=?",
|
||||
email, domain)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("Unable to prepare GetUserByDomain %s %s", domain, email))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&u, email, domain)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, fmt.Sprintf("Unable to execute GetUserByDomain %s %s", domain, email))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -95,18 +72,10 @@ func (s Scope) GetByDomain(ctx domain.RequestContext, domain, email string) (u u
|
|||
func (s Scope) GetByEmail(ctx domain.RequestContext, email string) (u user.User, err error) {
|
||||
email = strings.TrimSpace(strings.ToLower(email))
|
||||
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, created, revised FROM user WHERE TRIM(LOWER(email))=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&u, "SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, created, revised FROM user WHERE TRIM(LOWER(email))=?", email)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare select user by email %s", email))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&u, email)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute select user by email %s", email))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -114,18 +83,10 @@ func (s Scope) GetByEmail(ctx domain.RequestContext, email string) (u user.User,
|
|||
|
||||
// GetByToken returns a user record given a reset token value.
|
||||
func (s Scope) GetByToken(ctx domain.RequestContext, token string) (u user.User, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, created, revised FROM user WHERE reset=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get(&u, "SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, created, revised FROM user WHERE reset=?", token)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare user select by token %s", token))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&u, token)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute user select by token %s", token))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -135,18 +96,10 @@ func (s Scope) GetByToken(ctx domain.RequestContext, token string) (u user.User,
|
|||
// This occurs when we you share a folder with a new user and they have to complete
|
||||
// the onboarding process.
|
||||
func (s Scope) GetBySerial(ctx domain.RequestContext, serial string) (u user.User, err error) {
|
||||
stmt, err := s.Runtime.Db.Preparex("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, created, revised FROM user WHERE salt=?")
|
||||
defer streamutil.Close(stmt)
|
||||
err = s.Runtime.Db.Get("SELECT id, refid, firstname, lastname, email, initials, global, password, salt, reset, created, revised FROM user WHERE salt=?", serial)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare user select by serial %s", serial))
|
||||
return
|
||||
}
|
||||
|
||||
err = stmt.Get(&u, serial)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute user select by serial %s", serial))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -163,7 +116,6 @@ func (s Scope) GetActiveUsersForOrganization(ctx domain.RequestContext) (u []use
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("get active users by org %s", ctx.OrgID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -179,7 +131,6 @@ func (s Scope) GetUsersForOrganization(ctx domain.RequestContext) (u []user.User
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf(" get users for org %s", ctx.OrgID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -200,7 +151,6 @@ func (s Scope) GetSpaceUsers(ctx domain.RequestContext, spaceID string) (u []use
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("get space users for org %s", ctx.OrgID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -239,7 +189,6 @@ func (s Scope) GetVisibleUsers(ctx domain.RequestContext) (u []user.User, err er
|
|||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("get visible users for org %s user %s", ctx.OrgID, ctx.UserID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -250,19 +199,11 @@ func (s Scope) UpdateUser(ctx domain.RequestContext, u user.User) (err error) {
|
|||
u.Revised = time.Now().UTC()
|
||||
u.Email = strings.ToLower(u.Email)
|
||||
|
||||
stmt, err := ctx.Transaction.PrepareNamed(
|
||||
"UPDATE user SET firstname=:firstname, lastname=:lastname, email=:email, revised=:revised, initials=:initials WHERE refid=:refid")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.NamedExec(
|
||||
"UPDATE user SET firstname=:firstname, lastname=:lastname, email=:email, revised=:revised, initials=:initials WHERE refid=:refid", &u)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("prepare user update %s", u.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(&u)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("execute user update %s", u.RefID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -270,18 +211,11 @@ func (s Scope) UpdateUser(ctx domain.RequestContext, u user.User) (err error) {
|
|||
|
||||
// UpdateUserPassword updates a user record with new password and salt values.
|
||||
func (s Scope) UpdateUserPassword(ctx domain.RequestContext, userID, salt, password string) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE user SET salt=?, password=?, reset='' WHERE refid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE user SET salt=?, password=?, reset='' WHERE refid=?",
|
||||
salt, password, userID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare user update")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(salt, password, userID)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute user update")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -289,19 +223,10 @@ func (s Scope) UpdateUserPassword(ctx domain.RequestContext, userID, salt, passw
|
|||
|
||||
// DeactiveUser deletes the account record for the given userID and persister.Context.OrgID.
|
||||
func (s Scope) DeactiveUser(ctx domain.RequestContext, userID string) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("DELETE FROM account WHERE userid=? and orgid=?")
|
||||
defer streamutil.Close(stmt)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare user deactivation")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(userID, ctx.OrgID)
|
||||
_, err = ctx.Transaction.Exec("DELETE FROM account WHERE userid=? and orgid=?", userID, ctx.OrgID)
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute user deactivation")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -309,18 +234,10 @@ func (s Scope) DeactiveUser(ctx domain.RequestContext, userID string) (err error
|
|||
|
||||
// ForgotUserPassword sets the password to '' and the reset field to token, for a user identified by email.
|
||||
func (s Scope) ForgotUserPassword(ctx domain.RequestContext, email, token string) (err error) {
|
||||
stmt, err := ctx.Transaction.Preparex("UPDATE user SET reset=?, password='' WHERE LOWER(email)=?")
|
||||
defer streamutil.Close(stmt)
|
||||
_, err = ctx.Transaction.Exec("UPDATE user SET reset=?, password='' WHERE LOWER(email)=?", token, strings.ToLower(email))
|
||||
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "prepare password reset")
|
||||
return
|
||||
}
|
||||
|
||||
_, err = stmt.Exec(token, strings.ToLower(email))
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute password reset")
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -37,6 +37,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
deleteSpaceName: '',
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
let targets = _.reject(this.get('folders'), {
|
||||
id: this.get('folder').get('id')
|
||||
});
|
||||
|
@ -50,6 +52,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
},
|
||||
|
||||
didRender() {
|
||||
this._super(...arguments);
|
||||
this.renderTooltips();
|
||||
},
|
||||
|
||||
|
@ -82,6 +85,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
{{#layout/zone-content}}
|
||||
<div class="back-to-space">
|
||||
{{#link-to 'folder' model.folder.id model.folder.slug}}
|
||||
<div class="regular-button button-gray">
|
||||
<div class="regular-button button-nav">
|
||||
<i class="material-icons">arrow_back</i>
|
||||
<div class="name">{{model.folder.name}}</div>
|
||||
</div>
|
||||
|
|
|
@ -79,21 +79,6 @@ export default Ember.Service.extend({
|
|||
});
|
||||
},
|
||||
|
||||
getBatchedPages: function (documentId, payload) {
|
||||
let url = `documents/${documentId}/pages/batch`;
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: 'POST',
|
||||
data: payload
|
||||
}).then((pages) => {
|
||||
if (is.not.array(pages)) {
|
||||
pages = [];
|
||||
}
|
||||
|
||||
return pages;
|
||||
});
|
||||
},
|
||||
|
||||
changePageSequence: function (documentId, payload) {
|
||||
let url = `documents/${documentId}/pages/sequence`;
|
||||
|
||||
|
|
|
@ -9,41 +9,46 @@
|
|||
//
|
||||
// https://documize.com
|
||||
|
||||
// Theme-neutral colors
|
||||
$color-off-white: #f5f5f5;
|
||||
$color-off-black: #393939;
|
||||
$color-black: #000000;
|
||||
$color-white: #ffffff;
|
||||
$color-primary: #2667af;
|
||||
|
||||
$color-red: #d04134;
|
||||
$color-green: #4caf50;
|
||||
$color-blue: #2667af;
|
||||
$color-gray: #8b9096;
|
||||
$color-goldy: #cc9933;
|
||||
|
||||
$color-sidebar: #f3f5f8;
|
||||
$color-link: #0092d3;
|
||||
$color-border: #f3f5f8;
|
||||
|
||||
$color-input: #5a5a5a;
|
||||
$color-stroke: #e1e1e1;
|
||||
|
||||
$color-tooltip: #a1a1a1;
|
||||
$color-toast: #4c4c4c;
|
||||
$color-checkbox: #2667af;
|
||||
$color-card-active: #f7fcff;
|
||||
|
||||
$color-chip: #dff0f9;
|
||||
$color-chip-border: #daeaf3;
|
||||
$color-chip-text: #1b88e3;
|
||||
|
||||
$color-symbol-box: #dce5e8;
|
||||
$color-symbol-icon: #a4b8be;
|
||||
|
||||
$color-table-border: #e1e1e1;
|
||||
$color-table-header: #f5f5f5;
|
||||
$color-toolbar: #eeeeee;
|
||||
$color-wysiwyg: #3c3c3c;
|
||||
|
||||
$color-input: #5a5a5a;
|
||||
$color-stroke: #e1e1e1;
|
||||
$color-tooltip: #a1a1a1;
|
||||
$color-toast: #4c4c4c;
|
||||
|
||||
// Theme colors
|
||||
$color-primary: #2667af;
|
||||
$color-link: #0092d3;
|
||||
$color-border: #f3f5f8;
|
||||
|
||||
$color-checkbox: #0092d3;
|
||||
$color-card-active: #f7fcff;
|
||||
|
||||
$color-nav-button: #f2faff;
|
||||
$color-nav-button-text: #2667af;
|
||||
$color-nav-button-border: #dff0f9;
|
||||
|
||||
$color-sidebar: #f2faff;
|
||||
$color-sidebar-border: #dff0f9;
|
||||
$color-sidebar-text: $color-off-black;
|
||||
$color-sidebar-link: $color-link;
|
||||
|
||||
// Color utility classes for direct usage in HTML
|
||||
.color-white {
|
||||
color: $color-white !important;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
.zone-document-content {
|
||||
> .document-header-zone {
|
||||
padding: 20px 30px;
|
||||
border: 1px solid $color-stroke;
|
||||
@include border-radius(3px);
|
||||
background-color: $color-off-white;
|
||||
// padding: 20px 30px;
|
||||
// @include border-radius(3px);
|
||||
// border: 1px solid $color-stroke;
|
||||
// background-color: $color-off-white;
|
||||
}
|
||||
|
||||
.doc-title {
|
||||
font-size: 2rem;
|
||||
margin: 50px 0 10px;
|
||||
font-weight: normal;
|
||||
// color: $color-primary;
|
||||
}
|
||||
|
||||
.doc-excerpt {
|
||||
font-size: 1rem;
|
||||
font-size: 1.2rem;
|
||||
color: $color-gray;
|
||||
margin: 0 0 45px;
|
||||
}
|
||||
|
@ -31,7 +32,7 @@
|
|||
}
|
||||
|
||||
.edit-doc-excerpt {
|
||||
font-size: 1rem;
|
||||
font-size: 1.2rem;
|
||||
margin: 0 0 10px;
|
||||
color: $color-gray;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ $sidebar-width: 400px;
|
|||
}
|
||||
|
||||
#sidebar-wrapper {
|
||||
background-color: $color-off-white;
|
||||
z-index: 888;
|
||||
position: fixed;
|
||||
overflow-x: hidden;
|
||||
|
@ -19,12 +18,13 @@ $sidebar-width: 400px;
|
|||
width: 0;
|
||||
height: 100%;
|
||||
margin-left: -$sidebar-width;
|
||||
border-right: 1px solid $color-stroke;
|
||||
overflow-y: auto;
|
||||
-webkit-transition: all 0.5s ease;
|
||||
-moz-transition: all 0.5s ease;
|
||||
-o-transition: all 0.5s ease;
|
||||
transition: all 0.5s ease;
|
||||
background-color: $color-sidebar;
|
||||
border-right: 1px solid $color-sidebar-border;
|
||||
}
|
||||
|
||||
.page-container {
|
||||
|
@ -68,22 +68,30 @@ $sidebar-width: 400px;
|
|||
|
||||
.zone-sidebar-page-title {
|
||||
color: $color-primary;
|
||||
font-size: 1.3rem;
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.zone-sidebar-page-info {
|
||||
color: $color-gray;
|
||||
color: $color-black;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5rem;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
color: $color-sidebar-text !important;
|
||||
|
||||
a, a:visited {
|
||||
&:hover {
|
||||
color: $color-sidebar-link !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-wrapper {
|
||||
padding: 40px 20px 40px 20px;
|
||||
margin-left: 20px;
|
||||
margin: 0 20px;
|
||||
|
||||
.sidebar-panel {
|
||||
width: 300px;
|
||||
|
@ -101,6 +109,14 @@ $sidebar-width: 400px;
|
|||
background-color: $color-white;
|
||||
}
|
||||
}
|
||||
|
||||
color: $color-sidebar-text !important;
|
||||
|
||||
a, a:visited {
|
||||
&:hover {
|
||||
color: $color-sidebar-link !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.navigation {
|
||||
|
|
|
@ -242,11 +242,10 @@
|
|||
border: 1px solid $color-gray;
|
||||
}
|
||||
|
||||
.button-chip {
|
||||
background-color: $color-chip;
|
||||
color: $color-chip-text;
|
||||
border: 1px solid $color-chip-border;
|
||||
@include button-hover-state($color-chip);
|
||||
.button-nav {
|
||||
background-color: $color-nav-button;
|
||||
color: $color-nav-button-text;
|
||||
border: 1px solid $color-nav-button;
|
||||
}
|
||||
|
||||
.flat-button {
|
||||
|
|
|
@ -5,45 +5,17 @@
|
|||
height: 25px;
|
||||
line-height: 0;
|
||||
margin: 0 5px 10px 0;
|
||||
border: 1px solid $color-chip-border;
|
||||
background-color: $color-chip;
|
||||
color: $color-chip-text;
|
||||
|
||||
&:hover {
|
||||
> i.material-icons {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
border: 1px solid $color-gray;
|
||||
background-color: $color-gray;
|
||||
color: $color-white;
|
||||
|
||||
> .chip-text {
|
||||
display: inline-block;
|
||||
font-weight: 400;
|
||||
font-size: 1rem;
|
||||
color: $color-chip-text;
|
||||
color: $color-white;
|
||||
padding: 11px 10px 0 10px;
|
||||
letter-spacing: 0.7px;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
> i.material-icons {
|
||||
visibility: hidden;
|
||||
color: $color-chip-text;
|
||||
font-size: 13px;
|
||||
margin: 13px 8px 0 0;
|
||||
padding: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.chip-action {
|
||||
@extend .chip;
|
||||
background-color: $color-white;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
> .chip-text {
|
||||
color: $color-chip-text;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
.symbol {
|
||||
display: inline-block;
|
||||
border-radius: 2px;
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
padding: 0;
|
||||
line-height: 0;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
background-color: $color-symbol-box;
|
||||
|
||||
> .material-icons {
|
||||
font-size: 22px;
|
||||
margin-top: 20px;
|
||||
color: $color-symbol-icon;
|
||||
}
|
||||
}
|
|
@ -73,7 +73,6 @@
|
|||
@import "widget-radio";
|
||||
@import "widget-selection";
|
||||
@import "widget-sidebar-menu";
|
||||
@import "widget-symbol";
|
||||
@import "widget-tab";
|
||||
@import "widget-table";
|
||||
@import "widget-tooltip";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="back-to-space document-space">
|
||||
<div class="caption">Space</div>
|
||||
{{#link-to 'folder' folder.id folder.slug}}
|
||||
<div class="regular-button button-gray">
|
||||
<div class="regular-button button-nav">
|
||||
<i class="material-icons">arrow_back</i>
|
||||
<div class="name">{{folder.name}}</div>
|
||||
</div>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<div class="caption">Category</div>
|
||||
|
||||
{{#each selectedCategories as |cat|}}
|
||||
<div class="regular-button button-blue">{{cat.category}}</div>
|
||||
<div class="regular-button button-nav">{{cat.category}}</div>
|
||||
{{else}}
|
||||
{{#if canAddCategory}}
|
||||
{{#link-to 'folder.settings.category' folder.id folder.slug}}Manage{{/link-to}}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="document-tags">
|
||||
<div class="caption">Tag</div>
|
||||
{{#each tagz as |t index|}}
|
||||
<div class="regular-button button-chip" id="{{concat 'delete-tag-' index}}">{{concat '#' t}}</div>
|
||||
<div class="regular-button button-gray" id="{{concat 'delete-tag-' index}}">{{concat '#' t}}</div>
|
||||
{{/each}}
|
||||
{{#if canAdd}}
|
||||
<div class="regular-button button-white" id="document-tag-button">
|
||||
|
|
|
@ -94,7 +94,6 @@ func RegisterEndpoints(rt *env.Runtime, s *domain.Store) {
|
|||
|
||||
Add(rt, RoutePrefixPrivate, "documents/{documentID}/pages/level", []string{"POST", "OPTIONS"}, nil, page.ChangePageLevel)
|
||||
Add(rt, RoutePrefixPrivate, "documents/{documentID}/pages/sequence", []string{"POST", "OPTIONS"}, nil, page.ChangePageSequence)
|
||||
Add(rt, RoutePrefixPrivate, "documents/{documentID}/pages/batch", []string{"POST", "OPTIONS"}, nil, page.GetPagesBatch)
|
||||
Add(rt, RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}/revisions", []string{"GET", "OPTIONS"}, nil, page.GetRevisions)
|
||||
Add(rt, RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}/revisions/{revisionID}", []string{"GET", "OPTIONS"}, nil, page.GetDiff)
|
||||
Add(rt, RoutePrefixPrivate, "documents/{documentID}/pages/{pageID}/revisions/{revisionID}", []string{"POST", "OPTIONS"}, nil, page.Rollback)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue