2020-05-26 14:46:16 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2021-03-01 07:48:50 +00:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2020-05-26 14:46:16 +00:00
|
|
|
"time"
|
|
|
|
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
2020-05-26 14:46:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
2021-03-01 07:48:50 +00:00
|
|
|
Method domain.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
|
|
|
}
|
|
|
|
}
|