zitadel/internal/key/repository/view/model/key_query.go
Fabi 8bfa1a083c
feat: administrator (#271)
* feat: get views and failed events

* feat: get views and failed events

* feat: get views and failed events

* Update internal/view/repository/sequence.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* Update internal/view/repository/general_query.go

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2020-06-25 08:01:13 +02:00

66 lines
1.5 KiB
Go

package model
import (
key_model "github.com/caos/zitadel/internal/key/model"
global_model "github.com/caos/zitadel/internal/model"
"github.com/caos/zitadel/internal/view/repository"
)
type KeySearchRequest key_model.KeySearchRequest
type KeySearchQuery key_model.KeySearchQuery
type KeySearchKey key_model.KeySearchKey
func (req KeySearchRequest) GetLimit() uint64 {
return req.Limit
}
func (req KeySearchRequest) GetOffset() uint64 {
return req.Offset
}
func (req KeySearchRequest) GetSortingColumn() repository.ColumnKey {
if req.SortingColumn == key_model.KeySearchKeyUnspecified {
return nil
}
return KeySearchKey(req.SortingColumn)
}
func (req KeySearchRequest) GetAsc() bool {
return req.Asc
}
func (req KeySearchRequest) GetQueries() []repository.SearchQuery {
result := make([]repository.SearchQuery, len(req.Queries))
for i, q := range req.Queries {
result[i] = KeySearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
}
return result
}
func (req KeySearchQuery) GetKey() repository.ColumnKey {
return KeySearchKey(req.Key)
}
func (req KeySearchQuery) GetMethod() global_model.SearchMethod {
return req.Method
}
func (req KeySearchQuery) GetValue() interface{} {
return req.Value
}
func (key KeySearchKey) ToColumnName() string {
switch key_model.KeySearchKey(key) {
case key_model.KeySearchKeyID:
return KeyKeyID
case key_model.KeySearchKeyPrivate:
return KeyPrivate
case key_model.KeySearchKeyUsage:
return KeyUsage
case key_model.KeySearchKeyExpiry:
return KeyExpiry
default:
return ""
}
}