2020-06-25 06:12:29 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
|
|
global_model "github.com/caos/zitadel/internal/model"
|
|
|
|
"github.com/caos/zitadel/internal/view/repository"
|
|
|
|
)
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
type IAMMemberSearchRequest iam_model.IAMMemberSearchRequest
|
|
|
|
type IAMMemberSearchQuery iam_model.IAMMemberSearchQuery
|
|
|
|
type IAMMemberSearchKey iam_model.IAMMemberSearchKey
|
2020-06-25 06:12:29 +00:00
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (req IAMMemberSearchRequest) GetLimit() uint64 {
|
2020-06-25 06:12:29 +00:00
|
|
|
return req.Limit
|
|
|
|
}
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (req IAMMemberSearchRequest) GetOffset() uint64 {
|
2020-06-25 06:12:29 +00:00
|
|
|
return req.Offset
|
|
|
|
}
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (req IAMMemberSearchRequest) GetSortingColumn() repository.ColumnKey {
|
|
|
|
if req.SortingColumn == iam_model.IAMMemberSearchKeyUnspecified {
|
2020-06-25 06:12:29 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-08-26 07:56:23 +00:00
|
|
|
return IAMMemberSearchKey(req.SortingColumn)
|
2020-06-25 06:12:29 +00:00
|
|
|
}
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (req IAMMemberSearchRequest) GetAsc() bool {
|
2020-06-25 06:12:29 +00:00
|
|
|
return req.Asc
|
|
|
|
}
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (req IAMMemberSearchRequest) GetQueries() []repository.SearchQuery {
|
2020-06-25 06:12:29 +00:00
|
|
|
result := make([]repository.SearchQuery, len(req.Queries))
|
|
|
|
for i, q := range req.Queries {
|
2020-08-26 07:56:23 +00:00
|
|
|
result[i] = IAMMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
2020-06-25 06:12:29 +00:00
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (req IAMMemberSearchQuery) GetKey() repository.ColumnKey {
|
|
|
|
return IAMMemberSearchKey(req.Key)
|
2020-06-25 06:12:29 +00:00
|
|
|
}
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (req IAMMemberSearchQuery) GetMethod() global_model.SearchMethod {
|
2020-06-25 06:12:29 +00:00
|
|
|
return req.Method
|
|
|
|
}
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (req IAMMemberSearchQuery) GetValue() interface{} {
|
2020-06-25 06:12:29 +00:00
|
|
|
return req.Value
|
|
|
|
}
|
|
|
|
|
2020-08-26 07:56:23 +00:00
|
|
|
func (key IAMMemberSearchKey) ToColumnName() string {
|
|
|
|
switch iam_model.IAMMemberSearchKey(key) {
|
|
|
|
case iam_model.IAMMemberSearchKeyEmail:
|
|
|
|
return IAMMemberKeyEmail
|
|
|
|
case iam_model.IAMMemberSearchKeyFirstName:
|
|
|
|
return IAMMemberKeyFirstName
|
|
|
|
case iam_model.IAMMemberSearchKeyLastName:
|
|
|
|
return IAMMemberKeyLastName
|
|
|
|
case iam_model.IAMMemberSearchKeyUserName:
|
|
|
|
return IAMMemberKeyUserName
|
|
|
|
case iam_model.IAMMemberSearchKeyUserID:
|
|
|
|
return IAMMemberKeyUserID
|
|
|
|
case iam_model.IAMMemberSearchKeyIamID:
|
|
|
|
return IAMMemberKeyIamID
|
2020-06-25 06:12:29 +00:00
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|