-
Notifications
You must be signed in to change notification settings - Fork 485
/
metadata_query.go
64 lines (53 loc) · 1.59 KB
/
metadata_query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package model
import (
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/view/repository"
)
type MetadataSearchRequest domain.MetadataSearchRequest
type MetadataSearchQuery domain.MetadataSearchQuery
type MetadataSearchKey domain.MetadataSearchKey
func (req MetadataSearchRequest) GetLimit() uint64 {
return req.Limit
}
func (req MetadataSearchRequest) GetOffset() uint64 {
return req.Offset
}
func (req MetadataSearchRequest) GetSortingColumn() repository.ColumnKey {
if req.SortingColumn == domain.MetadataSearchKeyUnspecified {
return nil
}
return MetadataSearchKey(req.SortingColumn)
}
func (req MetadataSearchRequest) GetAsc() bool {
return req.Asc
}
func (req MetadataSearchRequest) GetQueries() []repository.SearchQuery {
result := make([]repository.SearchQuery, len(req.Queries))
for i, q := range req.Queries {
result[i] = MetadataSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
}
return result
}
func (req MetadataSearchQuery) GetKey() repository.ColumnKey {
return MetadataSearchKey(req.Key)
}
func (req MetadataSearchQuery) GetMethod() domain.SearchMethod {
return req.Method
}
func (req MetadataSearchQuery) GetValue() interface{} {
return req.Value
}
func (key MetadataSearchKey) ToColumnName() string {
switch domain.MetadataSearchKey(key) {
case domain.MetadataSearchKeyAggregateID:
return MetadataKeyAggregateID
case domain.MetadataSearchKeyResourceOwner:
return MetadataKeyResourceOwner
case domain.MetadataSearchKeyKey:
return MetadataKeyKey
case domain.MetadataSearchKeyValue:
return MetadataKeyValue
default:
return ""
}
}