2020-05-26 14:46:16 +00:00
|
|
|
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
|
|
|
|
|
2020-06-16 09:40:18 +00:00
|
|
|
Name string
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type OrgSearchRequest struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
SortingColumn OrgSearchKey
|
|
|
|
Asc bool
|
|
|
|
Queries []*OrgSearchQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
type OrgSearchKey int32
|
|
|
|
|
|
|
|
const (
|
2020-06-23 12:47:47 +00:00
|
|
|
OrgSearchKeyUnspecified OrgSearchKey = iota
|
|
|
|
OrgSearchKeyOrgID
|
|
|
|
OrgSearchKeyOrgName
|
|
|
|
OrgSearchKeyOrgDomain
|
|
|
|
OrgSearchKeyState
|
|
|
|
OrgSearchKeyResourceOwner
|
2020-05-26 14:46:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type OrgSearchQuery struct {
|
|
|
|
Key OrgSearchKey
|
|
|
|
Method model.SearchMethod
|
2020-06-16 09:40:18 +00:00
|
|
|
Value interface{}
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type OrgSearchResult struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
TotalResult uint64
|
|
|
|
Result []*OrgView
|
2020-07-15 11:24:36 +00:00
|
|
|
Sequence uint64
|
|
|
|
Timestamp time.Time
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
},
|
2020-06-16 09:40:18 +00:00
|
|
|
Name: o.Name,
|
|
|
|
State: o.State,
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
}
|