2020-06-15 14:50:39 +02:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2021-03-01 08:48:50 +01:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2020-06-15 14:50:39 +02:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectView struct {
|
2020-10-16 07:49:38 +02:00
|
|
|
ProjectID string
|
|
|
|
Name string
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
State ProjectState
|
|
|
|
ResourceOwner string
|
|
|
|
ProjectRoleAssertion bool
|
|
|
|
ProjectRoleCheck bool
|
|
|
|
Sequence uint64
|
2020-06-15 14:50:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type ProjectViewSearchRequest struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
SortingColumn ProjectViewSearchKey
|
|
|
|
Asc bool
|
|
|
|
Queries []*ProjectViewSearchQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
type ProjectViewSearchKey int32
|
|
|
|
|
|
|
|
const (
|
2020-06-23 14:47:47 +02:00
|
|
|
ProjectViewSearchKeyUnspecified ProjectViewSearchKey = iota
|
|
|
|
ProjectViewSearchKeyName
|
|
|
|
ProjectViewSearchKeyProjectID
|
|
|
|
ProjectViewSearchKeyResourceOwner
|
2020-06-15 14:50:39 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectViewSearchQuery struct {
|
|
|
|
Key ProjectViewSearchKey
|
2021-03-01 08:48:50 +01:00
|
|
|
Method domain.SearchMethod
|
2020-06-15 14:50:39 +02:00
|
|
|
Value interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ProjectViewSearchResponse struct {
|
|
|
|
Offset uint64
|
|
|
|
Limit uint64
|
|
|
|
TotalResult uint64
|
|
|
|
Result []*ProjectView
|
2020-07-15 13:24:36 +02:00
|
|
|
Sequence uint64
|
|
|
|
Timestamp time.Time
|
2020-06-15 14:50:39 +02:00
|
|
|
}
|
|
|
|
|
2020-07-22 14:00:29 +02:00
|
|
|
func (r *ProjectViewSearchRequest) GetSearchQuery(key ProjectViewSearchKey) (int, *ProjectViewSearchQuery) {
|
|
|
|
for i, q := range r.Queries {
|
|
|
|
if q.Key == key {
|
|
|
|
return i, q
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1, nil
|
|
|
|
}
|
|
|
|
|
2020-06-15 14:50:39 +02:00
|
|
|
func (r *ProjectViewSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
|
2021-03-01 08:48:50 +01:00
|
|
|
r.Queries = append(r.Queries, &ProjectViewSearchQuery{Key: ProjectViewSearchKeyResourceOwner, Method: domain.SearchMethodEquals, Value: orgID})
|
2020-06-15 14:50:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ProjectViewSearchRequest) EnsureLimit(limit uint64) {
|
|
|
|
if r.Limit == 0 || r.Limit > limit {
|
|
|
|
r.Limit = limit
|
|
|
|
}
|
|
|
|
}
|