feat: org queries (#136)

* search orgs

* org by domain

* member spooler

* member

* get roles

* tests

* types duration

* use default func for renew

* correct database

* reorder migrations

* delete unused consts

* move get roles to internal

* use prepared org by domain

* implement org in other objects

* add eventstores
This commit is contained in:
Silvan
2020-05-26 16:46:16 +02:00
committed by GitHub
parent a6aba86b54
commit 3025ac577b
52 changed files with 1732 additions and 164 deletions

View File

@@ -0,0 +1,59 @@
package model
import (
"time"
"github.com/caos/zitadel/internal/model"
)
type OrgMemberView struct {
UserID string
OrgID string
UserName string
Email string
FirstName string
LastName string
Roles []string
CreationDate time.Time
ChangeDate time.Time
Sequence uint64
}
type OrgMemberSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn OrgMemberSearchKey
Asc bool
Queries []*OrgMemberSearchQuery
}
type OrgMemberSearchKey int32
const (
ORGMEMBERSEARCHKEY_UNSPECIFIED OrgMemberSearchKey = iota
ORGMEMBERSEARCHKEY_USER_NAME
ORGMEMBERSEARCHKEY_EMAIL
ORGMEMBERSEARCHKEY_FIRST_NAME
ORGMEMBERSEARCHKEY_LAST_NAME
ORGMEMBERSEARCHKEY_ORG_ID
ORGMEMBERSEARCHKEY_USER_ID
)
type OrgMemberSearchQuery struct {
Key OrgMemberSearchKey
Method model.SearchMethod
Value string
}
type OrgMemberSearchResponse struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*OrgMemberView
}
func (r *OrgMemberSearchRequest) EnsureLimit(limit uint64) {
if r.Limit == 0 || r.Limit > limit {
r.Limit = limit
}
}

View File

@@ -0,0 +1,73 @@
package model
import (
"time"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/model"
)
type OrgView struct {
ID string
CreationDate time.Time
ChangeDate time.Time
State OrgState
ResourceOwner string
Sequence uint64
Name string
Domain string
}
type OrgSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn OrgSearchKey
Asc bool
Queries []*OrgSearchQuery
}
type OrgSearchKey int32
const (
ORGSEARCHKEY_UNSPECIFIED OrgSearchKey = iota
ORGSEARCHKEY_ORG_ID
ORGSEARCHKEY_ORG_NAME
ORGSEARCHKEY_ORG_DOMAIN
ORGSEARCHKEY_STATE
ORGSEARCHKEY_RESOURCEOWNER
)
type OrgSearchQuery struct {
Key OrgSearchKey
Method model.SearchMethod
Value string
}
type OrgSearchResult struct {
Offset uint64
Limit uint64
TotalResult uint64
Result []*OrgView
}
func (r *OrgSearchRequest) EnsureLimit(limit uint64) {
if r.Limit == 0 || r.Limit > limit {
r.Limit = limit
}
}
func OrgViewToOrg(o *OrgView) *Org {
return &Org{
ObjectRoot: models.ObjectRoot{
AggregateID: o.ID,
ChangeDate: o.ChangeDate,
CreationDate: o.CreationDate,
ResourceOwner: o.ResourceOwner,
Sequence: o.Sequence,
},
Domain: o.Domain,
Name: o.Name,
State: o.State,
}
}