mirror of
https://github.com/documize/community.git
synced 2025-07-23 15:19:42 +02:00
add category to document
This commit is contained in:
parent
508ec00c6a
commit
f0582e18f7
19 changed files with 334 additions and 58 deletions
|
@ -61,8 +61,7 @@ func (s Scope) GetBySpace(ctx domain.RequestContext, spaceID string) (c []catego
|
|||
WHERE orgid=? AND labelid=?
|
||||
AND refid IN (SELECT refid FROM permission WHERE orgid=? AND location='category' AND refid IN (
|
||||
SELECT refid from permission WHERE orgid=? AND who='user' AND whoid=? AND location='category' UNION ALL
|
||||
SELECT p.refid from permission p LEFT JOIN rolemember r ON p.whoid=r.roleid WHERE p.orgid=? AND p.who='role' AND p.location='category'
|
||||
AND p.action='view' AND r.userid=?
|
||||
SELECT p.refid from permission p LEFT JOIN rolemember r ON p.whoid=r.roleid WHERE p.orgid=? AND p.who='role' AND p.location='category' AND r.userid=?
|
||||
))
|
||||
ORDER BY category`, ctx.OrgID, spaceID, ctx.OrgID, ctx.OrgID, ctx.UserID, ctx.OrgID, ctx.UserID)
|
||||
|
||||
|
@ -225,3 +224,20 @@ func (s Scope) GetSpaceCategorySummary(ctx domain.RequestContext, spaceID string
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
// GetDocumentCategoryMembership returns all space categories associated with given document.
|
||||
func (s Scope) GetDocumentCategoryMembership(ctx domain.RequestContext, documentID string) (c []category.Category, err error) {
|
||||
err = s.Runtime.Db.Select(&c, `
|
||||
SELECT id, refid, orgid, labelid, category, created, revised FROM category
|
||||
WHERE orgid=? AND refid IN (SELECT categoryid FROM categorymember WHERE orgid=? AND documentid=?)`, ctx.OrgID, ctx.OrgID, documentID)
|
||||
|
||||
if err == sql.ErrNoRows {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, fmt.Sprintf("unable to execute select categories for document %s", documentID))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue