mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
WIP SQL Server support
This commit is contained in:
parent
64403c402b
commit
a41f43c380
9 changed files with 804 additions and 749 deletions
|
@ -239,13 +239,13 @@ func (s Store) GetSpaceCategorySummary(ctx domain.RequestContext, spaceID string
|
|||
GROUP BY c_groupid
|
||||
) AS x INNER JOIN dmz_doc AS d ON d.c_groupid=x.c_groupid AND d.c_versionorder=x.latestversion
|
||||
)
|
||||
GROUP BY c_categoryid, grouptype
|
||||
GROUP BY c_categoryid
|
||||
UNION ALL
|
||||
SELECT 'users' AS grouptype, c_refid AS categoryid, count(*) AS count
|
||||
FROM dmz_permission
|
||||
WHERE c_orgid=? AND c_location='category' AND c_refid IN
|
||||
(SELECT c_refid FROM dmz_category WHERE c_orgid=? AND c_spaceid=?)
|
||||
GROUP BY c_refid, grouptype`),
|
||||
GROUP BY c_refid`),
|
||||
ctx.OrgID, spaceID,
|
||||
ctx.OrgID, spaceID, ctx.OrgID, spaceID,
|
||||
ctx.OrgID, ctx.OrgID, spaceID)
|
||||
|
|
|
@ -61,10 +61,12 @@ func (s Store) Add(ctx domain.RequestContext, model page.NewPage) (err error) {
|
|||
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_section (c_refid, c_orgid, c_docid, c_userid, c_contenttype, c_type, c_level, c_name, c_body, c_revisions, c_sequence, c_templateid, c_status, c_relativeid, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"),
|
||||
model.Page.RefID, model.Page.OrgID, model.Page.DocumentID, model.Page.UserID, model.Page.ContentType, model.Page.Type, model.Page.Level, model.Page.Name, model.Page.Body, model.Page.Revisions, model.Page.Sequence, model.Page.TemplateID, model.Page.Status, model.Page.RelativeID, model.Page.Created, model.Page.Revised)
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "execute page insert")
|
||||
}
|
||||
|
||||
_, err = ctx.Transaction.Exec(s.Bind("INSERT INTO dmz_section_meta (c_sectionid, c_orgid, c_userid, c_docid, c_rawbody, c_config, c_external, c_created, c_revised) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"),
|
||||
model.Meta.SectionID, 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")
|
||||
}
|
||||
|
@ -241,7 +243,7 @@ func (s Store) GetPageMeta(ctx domain.RequestContext, pageID string) (meta page.
|
|||
c_orgid AS orgid, c_userid AS userid, c_docid AS documentid,
|
||||
c_rawbody AS rawbody, coalesce(c_config,`+s.EmptyJSON()+`) as config,
|
||||
c_external AS externalsource, c_created AS created, c_revised AS revised
|
||||
FROM dmz_section_meta
|
||||
FROM dmz_section_meta
|
||||
WHERE c_orgid=? AND c_sectionid=?`),
|
||||
ctx.OrgID, pageID)
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ package search
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/domain"
|
||||
"github.com/documize/community/model/attachment"
|
||||
"github.com/documize/community/model/category"
|
||||
|
@ -25,6 +27,10 @@ import (
|
|||
// IndexDocument adds search indesd entries for document inserting title, tags and attachments as
|
||||
// searchable items. Any existing document entries are removed.
|
||||
func (m *Indexer) IndexDocument(ctx domain.RequestContext, d doc.Document, a []attachment.Attachment) {
|
||||
if m.runtime.StoreProvider.Type() == env.StoreTypeSQLServer {
|
||||
return
|
||||
}
|
||||
|
||||
method := "search.IndexDocument"
|
||||
var err error
|
||||
|
||||
|
@ -47,6 +53,10 @@ func (m *Indexer) IndexDocument(ctx domain.RequestContext, d doc.Document, a []a
|
|||
|
||||
// DeleteDocument removes all search entries for document.
|
||||
func (m *Indexer) DeleteDocument(ctx domain.RequestContext, ID string) {
|
||||
if m.runtime.StoreProvider.Type() == env.StoreTypeSQLServer {
|
||||
return
|
||||
}
|
||||
|
||||
method := "search.DeleteDocument"
|
||||
var err error
|
||||
|
||||
|
@ -70,6 +80,10 @@ func (m *Indexer) DeleteDocument(ctx domain.RequestContext, ID string) {
|
|||
// IndexContent adds search index entry for document context.
|
||||
// Any existing document entries are removed.
|
||||
func (m *Indexer) IndexContent(ctx domain.RequestContext, p page.Page) {
|
||||
if m.runtime.StoreProvider.Type() == env.StoreTypeSQLServer {
|
||||
return
|
||||
}
|
||||
|
||||
method := "search.IndexContent"
|
||||
var err error
|
||||
|
||||
|
@ -97,6 +111,10 @@ func (m *Indexer) IndexContent(ctx domain.RequestContext, p page.Page) {
|
|||
|
||||
// DeleteContent removes all search entries for specific document content.
|
||||
func (m *Indexer) DeleteContent(ctx domain.RequestContext, pageID string) {
|
||||
if m.runtime.StoreProvider.Type() == env.StoreTypeSQLServer {
|
||||
return
|
||||
}
|
||||
|
||||
method := "search.DeleteContent"
|
||||
var err error
|
||||
|
||||
|
|
|
@ -15,10 +15,11 @@ import (
|
|||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/documize/community/model/category"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/documize/community/model/category"
|
||||
|
||||
"github.com/documize/community/core/env"
|
||||
"github.com/documize/community/core/event"
|
||||
"github.com/documize/community/core/request"
|
||||
|
@ -36,6 +37,7 @@ import (
|
|||
"github.com/documize/community/model/doc"
|
||||
"github.com/documize/community/model/page"
|
||||
pm "github.com/documize/community/model/permission"
|
||||
|
||||
// "github.com/documize/community/model/template"
|
||||
"github.com/documize/community/model/workflow"
|
||||
uuid "github.com/nu7hatch/gouuid"
|
||||
|
@ -336,12 +338,7 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
ctx.Transaction, err = h.Runtime.Db.Beginx()
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
ctx.Transaction, _ = h.Runtime.StartTx(sql.LevelReadUncommitted)
|
||||
|
||||
// Prepare new document
|
||||
documentID = uniqueid.Generate()
|
||||
|
@ -386,11 +383,10 @@ func (h *Handler) Use(w http.ResponseWriter, r *http.Request) {
|
|||
model.Meta = meta
|
||||
|
||||
err = h.Store.Page.Add(ctx, model)
|
||||
|
||||
if err != nil {
|
||||
h.Runtime.Log.Error(method, err)
|
||||
ctx.Transaction.Rollback()
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue