mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +02:00
add/remove group membership
This commit is contained in:
parent
0b5ed8fd9e
commit
ed11c0ad11
17 changed files with 287 additions and 87 deletions
|
@ -141,3 +141,25 @@ func (s Scope) LeaveGroup(ctx domain.RequestContext, groupID, userID string) (er
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
// GetMembers returns members for every group.
|
||||
// Useful when you need to bulk fetch membership records
|
||||
// for subsequent processing.
|
||||
func (s Scope) GetMembers(ctx domain.RequestContext) (r []group.Record, err error) {
|
||||
err = s.Runtime.Db.Select(&r,
|
||||
`SELECT a.id, a.orgid, a.roleid, a.userid, b.role as name, b.purpose
|
||||
FROM rolemember a, role b
|
||||
WHERE a.orgid=? AND a.roleid=b.refid
|
||||
ORDER BY a.userid`,
|
||||
ctx.OrgID)
|
||||
|
||||
if err == sql.ErrNoRows || len(r) == 0 {
|
||||
err = nil
|
||||
r = []group.Record{}
|
||||
}
|
||||
if err != nil {
|
||||
err = errors.Wrap(err, "select group members")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue